Handled storage of absolute image urls#10025
Conversation
b5d94ef to
8ba51cf
Compare
refs TryGhost#10024 - Updated input serializers for posts/tags/users to handle absolute urls conversion
8ba51cf to
c455872
Compare
| } | ||
| } | ||
|
|
||
| frame.data.posts[0] = url.forPost(Object.assign({}, frame.data.posts[0]), frame.options); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
|
|
||
| function handleImageUrl(imageUrl) { | ||
| let blogUrl = getBlogUrl(); | ||
| if (url.parse(imageUrl).host === url.parse(blogUrl).host) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
|
@gargol Could you pls review and do a functional test (including subdirectory)? I'll do a final review asap 👍 Thank you :) |
e90255e to
d472734
Compare
| const url = require('./utils/url'); | ||
|
|
||
| module.exports = { | ||
| edit(apiConfig, frame) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| const url = require('./utils/url'); | ||
|
|
||
| module.exports = { | ||
| edit(apiConfig, frame) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| const {absoluteToRelative, getBlogUrl, STATIC_IMAGE_URL_PREFIX} = require('../../../../../../services/url/utils'); | ||
|
|
||
| function handleImageUrl(imageUrl) { | ||
| let blogUrl = getBlogUrl().replace(/^http(s?):\/\//, '').replace(/\/$/, ''); |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
| @@ -0,0 +1,67 @@ | |||
| const {absoluteToRelative, getBlogUrl, STATIC_IMAGE_URL_PREFIX} = require('../../../../../../services/url/utils'); | |||
|
|
|||
| function handleImageUrl(imageUrl) { | |||
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
|
Found an issue during testing, image url is not properly handled when moving blog to a subdir: |
|
Discussed #10025 (comment) : Its not caused by changes here, there are known problems in changing domains/blog url right now since content is not re-written, so will not be patched in this PR. |
To clarify, changing subdomains is a manual process because we don't know which stored URLs are meant to be relative ghost root and which are meant to be relative to the domain root. We'll open separate issues and PRs to handle that side of things if it's something we want to try automating in the future. |
refs #10024
Current behavior: This will override the relative image path in db to absolute, which in turn won't get updated in future if domain or protocol changes for e.g.
Fix: On save/update, input serializers converts any absolute image url paths back to relative if the base URL from image fields matches the configured URL