mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 02:44:33 +03:00
Fix front-end URL output for more URL schemes
- allows direct pass-through of protocol-relative (`//host`), alternate-scheme (`tel:`), and anchor-only urls (`#contact`)
This commit is contained in:
parent
b160cd2e32
commit
621b633079
@ -210,7 +210,8 @@ function urlFor(context, data, absolute) {
|
||||
}
|
||||
|
||||
// This url already has a protocol so is likely an external url to be returned
|
||||
if (urlPath && (urlPath.indexOf('://') !== -1 || urlPath.indexOf('mailto:') === 0)) {
|
||||
// or it is an anchor-only path
|
||||
if (urlPath && (urlPath.indexOf('://') !== -1 || urlPath.match(/^(\/\/|#|[a-zA-Z0-9-]*:)/))) {
|
||||
return urlPath;
|
||||
}
|
||||
|
||||
|
@ -151,4 +151,10 @@ describe('{{url}} helper', function () {
|
||||
should.exist(rendered);
|
||||
rendered.should.equal('http://casper.website/baz');
|
||||
});
|
||||
|
||||
it('should pass through protocol-relative URLs');
|
||||
|
||||
it('should pass through URLs with alternative schemes');
|
||||
|
||||
it('should pass through anchor-only URLs');
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user