diff --git a/app/assets/javascripts/discourse/app/routes/post.js b/app/assets/javascripts/discourse/app/routes/post.js
index 8d8bb40d66d..4fcfdba5a6c 100644
--- a/app/assets/javascripts/discourse/app/routes/post.js
+++ b/app/assets/javascripts/discourse/app/routes/post.js
@@ -1,17 +1,14 @@
import DiscourseRoute from "discourse/routes/discourse";
-import { ajax } from "discourse/lib/ajax";
+import { inject as service } from "@ember/service";
export default DiscourseRoute.extend({
- beforeModel({ params, _discourse_anchor }) {
- return ajax(`/p/${params.post.id}`).then((t) => {
- const transition = this.transitionTo(
- "topic.fromParamsNear",
- t.slug,
- t.id,
- t.current_post_number
- );
+ router: service(),
- transition._discourse_anchor = _discourse_anchor;
- });
+ model(params) {
+ return this.store.find("post", params.id);
+ },
+
+ afterModel(post) {
+ this.router.transitionTo(post.url);
},
});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/topic-test.js b/app/assets/javascripts/discourse/tests/acceptance/topic-test.js
index 0bdfa70f49f..5caa7455f2e 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/topic-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/topic-test.js
@@ -588,6 +588,7 @@ acceptance("Navigating between topics", function (needs) {
firstPost.cooked += `\nLink 2`;
firstPost.cooked += `\nLink 3`;
firstPost.cooked += `\nLink 3`;
+ firstPost.cooked += `\nLink to Post`;
server.get("/t/280.json", () => helper.response(topicResponse));
server.get("/t/280/:post_number.json", () =>
@@ -617,4 +618,10 @@ acceptance("Navigating between topics", function (needs) {
await click("a.diff-topic-slugless-post");
assert.ok(currentURL().includes("/281"));
});
+
+ test("clicking post URLs", async function (assert) {
+ await visit("/t/-/280");
+ await click("a.by-post-id");
+ assert.ok(currentURL().includes("/280"));
+ });
});