Ghost/core/server/helpers
Fabien O'Carroll a2aa66ca73
🐛 Fixed img-url to output relative url by default (#10596)
closes #10595

* Added breaking test for img-url helper

Input from the content API was absolute, adding this test to verify my fix

* Updated existing test to breaking test for img-url

Had made a dumb assumption when building images sizes, this updates the
test to fail so we can verify the fix

* Refactored img-url to return as early as possible

This makes it a little easier to parse what's going on, and it also
allows us to remove the check for existence of the image url in the
getImageSizes function

* Refactored img-url config parsing to clean up core logic

Superficial refactor to make future changes able to focus on what rather
than how.

* Refactored internal image detection into helper

We're gonna need to know if the image is internal or not, when we force
the path to relative, if we pull this out now, we have access in the top
level logic

* Removed duplicate checks for internal image

Cleaning up and moving "higher-level" logic into the main function of
the module

* Renamed attr -> requestedImageUrl

Superficial refactor, trying to be more explicit about identifiers

* 🐛 Fixed img-url to output relative url by default

Includes a check to isInternalImage as we never want to make external
images relative.

* Returned early if img-url recieves external url

After realising we never want to deal with external urls, we can
continue to return as early as possible, letting us remove checks and
simplify the more complex logic for internal images.

* Cleaned up the internal image logic

Defining the three functions in order helps to see what operations are
going to happen and in which order, we can then return the result of
each operation applied to the next operation.
2019-03-11 15:20:05 +01:00
..
tpl 🎨 Added additional parameters to subscribe_form and input_email helpers (#9820) 2018-08-30 17:17:27 +01:00
asset.js Fixed single lodash import 2018-06-04 22:44:41 +02:00
author.js Changed comments and deprecation notes 2018-08-16 12:13:24 +02:00
authors.js 🐛 Fixed preview url and Zapier on subdirectory (#9683) 2018-06-12 16:36:58 +01:00
body_class.js Switched to eslint-plugin-ghost (#9835) 2018-09-17 20:49:30 +02:00
content.js Helper Proxy & single express-hbs instance (#8225) 2017-04-04 18:07:35 +02:00
date.js Theme translations and blog localisation (#8437) 2018-01-09 14:50:57 +01:00
encode.js Helper Proxy & single express-hbs instance (#8225) 2017-04-04 18:07:35 +02:00
excerpt.js 🐛 Fixed returning 'null' text for exerpt helper 2019-03-04 14:39:20 +08:00
facebook_url.js Fixed comment in facebook_url helper (#9430) 2018-01-28 18:25:06 +01:00
foreach.js Moved visibility utility to static model fn (#9327) 2017-12-13 13:19:51 +01:00
get.js Updated TODO's 2019-02-27 18:08:36 +01:00
ghost_foot.js Switch to Eslint (#9197) 2017-11-01 13:44:54 +00:00
ghost_head.js 🐛Disallowed indexing of preview pages (#9762) 2018-09-17 11:29:47 +02:00
has.js Switched to eslint-plugin-ghost (#9835) 2018-09-17 20:49:30 +02:00
img_url.js 🐛 Fixed img-url to output relative url by default (#10596) 2019-03-11 15:20:05 +01:00
index.js Multiple authors (#9426) 2018-03-27 15:16:15 +01:00
is.js Helper Proxy & single express-hbs instance (#8225) 2017-04-04 18:07:35 +02:00
lang.js Theme translations and blog localisation (#8437) 2018-01-09 14:50:57 +01:00
meta_description.js Switch to Eslint (#9197) 2017-11-01 13:44:54 +00:00
meta_title.js 🐛Fixed i18n for the {{meta_title}} helper (#9468) 2018-03-19 09:48:07 +01:00
navigation.js Attr pass-thru & full context in partial helpers 2019-03-09 21:21:01 +00:00
page_url.js Switch to Eslint (#9197) 2017-11-01 13:44:54 +00:00
pagination.js Attr pass-thru & full context in partial helpers 2019-03-09 21:21:01 +00:00
plural.js Theme translations and blog localisation (#8437) 2018-01-09 14:50:57 +01:00
post_class.js Switch to Eslint (#9197) 2017-11-01 13:44:54 +00:00
prev_next.js Updated TODO's 2019-02-27 18:08:36 +01:00
proxy.js Dynamic Routing Beta (#9596) 2018-06-05 19:02:20 +02:00
reading_time.js 🎨Removed seconds option from {{reading_time}} (#9573) 2018-04-18 10:55:08 +08:00
register.js Moved labs, auth, permissions, settings, mail, themes to services (#9339) 2017-12-14 03:01:23 +01:00
t.js Theme translations and blog localisation (#8437) 2018-01-09 14:50:57 +01:00
tags.js 🐛 Fixed preview url and Zapier on subdirectory (#9683) 2018-06-12 16:36:58 +01:00
template.js Attr pass-thru & full context in partial helpers 2019-03-09 21:21:01 +00:00
title.js Helper Proxy & single express-hbs instance (#8225) 2017-04-04 18:07:35 +02:00
twitter_url.js Moved social utility to lib/social 2017-12-14 22:34:05 +01:00
url.js 🐛 Supported "false" as absolute attribute value (#10556) 2019-03-04 11:23:42 +01:00
utils.js 🐛 Returned 0 for word/image count when html is null 2019-01-29 13:35:00 +01:00