Ghost/core/server/helpers/url.js
Fabien O'Carroll d7238e94c2
🐛 Supported "false" as absolute attribute value (#10556)
no-issue

* Added breaking test
* 🐛 Supported "false" as absolute attribute value

refs https://github.com/TryGhost/docs-api/pull/29
2019-03-04 11:23:42 +01:00

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);
};