mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-30 06:12:03 +03:00
d7238e94c2
no-issue * Added breaking test * 🐛 Supported "false" as absolute attribute value refs https://github.com/TryGhost/docs-api/pull/29
19 lines
627 B
JavaScript
19 lines
627 B
JavaScript
// # URL helper
|
|
// Usage: `{{url}}`, `{{url absolute="true"}}`
|
|
//
|
|
// Returns the URL for the current object scope i.e. If inside a post scope will return post permalink
|
|
// `absolute` flag outputs absolute URL, else URL is relative
|
|
|
|
var proxy = require('./proxy'),
|
|
SafeString = proxy.SafeString,
|
|
getMetaDataUrl = proxy.metaData.getMetaDataUrl;
|
|
|
|
module.exports = function url(options) {
|
|
var absolute = options && options.hash.absolute && options.hash.absolute !== 'false',
|
|
outputUrl = getMetaDataUrl(this, absolute);
|
|
|
|
outputUrl = encodeURI(decodeURI(outputUrl));
|
|
|
|
return new SafeString(outputUrl);
|
|
};
|