FIX: Make addNavigationBarItem subfolder compatible (#11101)

@danielwaterworth suggested taking a look at this when reviewing a plugin using this API. 

When declaring a new nav item using `addNavigationBarItem` and including the `href` attribute, we don't currently process that URL to be subfolder compatible. 

Nav bar items coming in via the API are considered `ExtraNavItem` and the `href` value is passed straight through to the `buildItems` method, vs using the computed href method. This PR adds a simple `getURL` call on that href value to ensure it's subfolder-safe.

I also accounted for the `customHref` function in the API to make those URLs subfolder safe as well.

<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in Javascript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
This commit is contained in:
Justin DiRose 2020-11-02 11:30:23 -06:00 committed by GitHub
parent 5041ebe612
commit 03cd5baed9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,7 +48,7 @@ const NavItem = EmberObject.extend({
}, this);
if (customHref) {
return customHref;
return getURL(customHref);
}
const context = { category, noSubcategories, tagId };
@ -245,6 +245,10 @@ NavItem.reopenClass({
item.init(item, category, args);
}
if (item.href) {
item.href = getURL(item.href);
}
const before = item.before;
if (before) {
let i = 0;