FIX: incorrect URL for tag pages inside category in subfolder setup. (#12222)

Previosuly, we didn't use `getURL` method to include the subfolder prefix in these places.
This commit is contained in:
Vinoth Kannan 2021-02-26 22:44:34 +05:30 committed by GitHub
parent e74bdfdf8e
commit 0581c033d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 6 deletions

View File

@ -1,6 +1,7 @@
import Component from "@ember/component"; import Component from "@ember/component";
import DiscourseURL from "discourse/lib/url"; import DiscourseURL from "discourse/lib/url";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
import getURL from "discourse-common/lib/get-url";
export default Component.extend({ export default Component.extend({
tagName: "a", tagName: "a",
@ -14,11 +15,15 @@ export default Component.extend({
@discourseComputed("tagId", "category") @discourseComputed("tagId", "category")
href(tagId, category) { href(tagId, category) {
let path;
if (category) { if (category) {
return "/tags" + category.url + "/" + tagId; path = "/tags" + category.path + "/" + tagId;
} else { } else {
return "/tag/" + tagId; path = "/tag/" + tagId;
} }
return getURL(path);
}, },
@discourseComputed("tagId") @discourseComputed("tagId")

View File

@ -498,7 +498,7 @@ export function getCategoryAndTagUrl(category, subcategories, tag) {
let url; let url;
if (category) { if (category) {
url = category.url; url = category.path;
if (!subcategories) { if (!subcategories) {
url += "/none"; url += "/none";
} }
@ -510,7 +510,7 @@ export function getCategoryAndTagUrl(category, subcategories, tag) {
: "/tag/" + tag.toLowerCase(); : "/tag/" + tag.toLowerCase();
} }
return url || "/"; return getURL(url || "/");
} }
export default _urlInstance; export default _urlInstance;

View File

@ -128,8 +128,13 @@ const Category = RestModel.extend({
}, },
@discourseComputed("name") @discourseComputed("name")
url() { path() {
return getURL(`/c/${Category.slugFor(this)}/${this.id}`); return `/c/${Category.slugFor(this)}/${this.id}`;
},
@discourseComputed("path")
url(path) {
return getURL(path);
}, },
@discourseComputed @discourseComputed