mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
🐛 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
This commit is contained in:
parent
42c472feff
commit
d7238e94c2
@ -19,7 +19,7 @@ module.exports = function imgUrl(attr, options) {
|
||||
return;
|
||||
}
|
||||
|
||||
const absolute = options && options.hash && options.hash.absolute;
|
||||
const absolute = options && options.hash && options.hash.absolute && options.hash.absolute !== 'false';
|
||||
|
||||
const size = options && options.hash && options.hash.size;
|
||||
const imageSizes = options && options.data && options.data.config && options.data.config.image_sizes;
|
||||
|
@ -9,7 +9,7 @@ var proxy = require('./proxy'),
|
||||
getMetaDataUrl = proxy.metaData.getMetaDataUrl;
|
||||
|
||||
module.exports = function url(options) {
|
||||
var absolute = options && options.hash.absolute,
|
||||
var absolute = options && options.hash.absolute && options.hash.absolute !== 'false',
|
||||
outputUrl = getMetaDataUrl(this, absolute);
|
||||
|
||||
outputUrl = encodeURI(decodeURI(outputUrl));
|
||||
|
@ -39,6 +39,12 @@ describe('{{image}} helper', function () {
|
||||
logWarnStub.called.should.be.false();
|
||||
});
|
||||
|
||||
it('should NOT output absolute url of image if the option is "false" ', function () {
|
||||
var rendered = helpers.img_url('/content/images/image-relative-url.png', {hash: {absolute: 'false'}});
|
||||
should.exist(rendered);
|
||||
rendered.should.equal('/content/images/image-relative-url.png');
|
||||
});
|
||||
|
||||
it('should output author url', function () {
|
||||
var rendered = helpers.img_url('/content/images/author-image-relative-url.png', {});
|
||||
should.exist(rendered);
|
||||
|
@ -60,7 +60,7 @@ describe('{{url}} helper', function () {
|
||||
created_at: new Date(0)
|
||||
});
|
||||
|
||||
urlService.getUrlByResourceId.withArgs(post.id, {absolute: 'true', secure: undefined, withSubdirectory: true}).returns('http://localhost:82832/slug/');
|
||||
urlService.getUrlByResourceId.withArgs(post.id, {absolute: true, secure: undefined, withSubdirectory: true}).returns('http://localhost:82832/slug/');
|
||||
|
||||
rendered = helpers.url.call(post, {hash: {absolute: 'true'}});
|
||||
should.exist(rendered);
|
||||
@ -78,7 +78,7 @@ describe('{{url}} helper', function () {
|
||||
secure: true
|
||||
});
|
||||
|
||||
urlService.getUrlByResourceId.withArgs(post.id, {absolute: 'true', secure: true, withSubdirectory: true}).returns('https://localhost:82832/slug/');
|
||||
urlService.getUrlByResourceId.withArgs(post.id, {absolute: true, secure: true, withSubdirectory: true}).returns('https://localhost:82832/slug/');
|
||||
|
||||
rendered = helpers.url.call(post, {hash: {absolute: 'true'}});
|
||||
should.exist(rendered);
|
||||
|
Loading…
Reference in New Issue
Block a user