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
date.js
encode.js
excerpt.js 🐛 Fixed returning 'null' text for exerpt helper 2019-03-04 14:39:20 +08:00
facebook_url.js
foreach.js
get.js Updated TODO's 2019-02-27 18:08:36 +01:00
ghost_foot.js
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
is.js
lang.js
meta_description.js
meta_title.js
navigation.js Attr pass-thru & full context in partial helpers 2019-03-09 21:21:01 +00:00
page_url.js
pagination.js Attr pass-thru & full context in partial helpers 2019-03-09 21:21:01 +00:00
plural.js
post_class.js
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
register.js
t.js
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
twitter_url.js
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