mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 11:54:33 +03: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
@ -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
|
||||
// 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
|
||||
if (!options.hash.for) {
|
||||
if (!options.hash.for || options.hash.for.string === '') {
|
||||
options.hash.for = '';
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,12 @@ describe('{{link_class}} helper', function () {
|
||||
.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 () {
|
||||
it('gets applied correctly', function () {
|
||||
// Test matching relative URL
|
||||
|
Loading…
Reference in New Issue
Block a user