mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
🐛 Fixed 404 errors if navigation URLs are somehow blank
no issue - in very rare circumstances it's possible that a navigation url in settings can be blank, we should not throw errors in this case as it appears as a theme/routing problem which is difficult to diagnose and much worse than simply not outputting a link class
This commit is contained in:
parent
e290983042
commit
bc63f51fd7
2 changed files with 7 additions and 1 deletions
|
@ -18,7 +18,7 @@ module.exports = function link_class(options) { // eslint-disable-line camelcase
|
||||||
// If the for attribute is present but empty, this is probably a dynamic data problem, hard for theme devs to track down
|
// If the for attribute is present but empty, this is probably a dynamic data problem, hard for theme devs to track down
|
||||||
// E.g. {{link_class for=slug}} in a context where slug returns an empty string
|
// E.g. {{link_class for=slug}} in a context where slug returns an empty string
|
||||||
// Error's here aren't useful (same as with empty get helper filters) so we fallback gracefully
|
// Error's here aren't useful (same as with empty get helper filters) so we fallback gracefully
|
||||||
if (!options.hash.for) {
|
if (!options.hash.for || options.hash.for.string === '') {
|
||||||
options.hash.for = '';
|
options.hash.for = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,12 @@ describe('{{link_class}} helper', function () {
|
||||||
.should.eql('');
|
.should.eql('');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('silently accepts an empty SafeString', function () {
|
||||||
|
compile('{{link_class for=blank_safe_string}}')
|
||||||
|
.with({blank_safe_string: new handlebars.SafeString('')})
|
||||||
|
.should.eql('');
|
||||||
|
});
|
||||||
|
|
||||||
describe('activeClass', function () {
|
describe('activeClass', function () {
|
||||||
it('gets applied correctly', function () {
|
it('gets applied correctly', function () {
|
||||||
// Test matching relative URL
|
// Test matching relative URL
|
||||||
|
|
Loading…
Add table
Reference in a new issue