FIX: Generate redirect URL correctly when using a subdirectory

The url property of a category contains the base_uri and so it shouldn't
be concatated into a larger URL unless it is the prefix.
This commit is contained in:
Daniel Waterworth 2019-11-29 14:58:08 +00:00
parent c414db107c
commit 9251065768
1 changed files with 11 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import DiscourseURL from "discourse/lib/url";
import TagsMixin from "select-kit/mixins/tags"; import TagsMixin from "select-kit/mixins/tags";
import { default as discourseComputed } from "discourse-common/utils/decorators"; import { default as discourseComputed } from "discourse-common/utils/decorators";
const { isEmpty, run } = Ember; const { isEmpty, run } = Ember;
import Category from "discourse/models/category";
export default ComboBoxComponent.extend(TagsMixin, { export default ComboBoxComponent.extend(TagsMixin, {
pluginApiIdentifiers: ["tag-drop"], pluginApiIdentifiers: ["tag-drop"],
@ -78,12 +79,14 @@ export default ComboBoxComponent.extend(TagsMixin, {
} }
}, },
@discourseComputed("firstCategory", "secondCategory") @discourseComputed("currentCategory")
noTagsUrl() { noTagsUrl(currentCategory) {
var url = "/tags"; let url = "/tags";
if (this.currentCategory) {
url += this.get("currentCategory.url"); if (currentCategory) {
url += `/c/${Category.slugFor(currentCategory)}`;
} }
return Discourse.getURL(`${url}/none`); return Discourse.getURL(`${url}/none`);
}, },
@ -157,9 +160,11 @@ export default ComboBoxComponent.extend(TagsMixin, {
url = Discourse.getURL(this.noTagsUrl); url = Discourse.getURL(this.noTagsUrl);
} else { } else {
url = "/tags"; url = "/tags";
if (this.currentCategory) { if (this.currentCategory) {
url += this.get("currentCategory.url"); url += `/c/${Category.slugFor(this.currentCategory)}`;
} }
url = Discourse.getURL(`${url}/${tagId.toLowerCase()}`); url = Discourse.getURL(`${url}/${tagId.toLowerCase()}`);
} }