You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are other problems also introduced by this: if the prefix is a fully-qualified-domain (meaning URLs are not relative), as that is not expected and pathprefix is always computed, urls become incorrect, due to some logic incorrectly replacing // with / in several places (https://example.com/foo becomes https:/example.com/foo).
Description
Gatsby transformer remark doesn't work properly when used together with
assetPrefix
. The plugin was not modified with #12128Before
assetPrefix
was introduced, all relative links where always prefixed with pathPrefix. AfterassetPrefix
was introduced, links are prefixed either withpathPrefix
orassetPrefix
, which is incorrect: assetPrefix should never be used to prefix links (see for example: https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-transformer-remark/src/extend-node-type.js#L206).There are other problems also introduced by this: if the prefix is a fully-qualified-domain (meaning URLs are not relative), as that is not expected and pathprefix is always computed, urls become incorrect, due to some logic incorrectly replacing
//
with/
in several places (https://example.com/foo
becomeshttps:/example.com/foo
).https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-transformer-remark/src/extend-node-type.js#L324
https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-transformer-remark/src/extend-node-type.js#L63
Ideally, all URL management should be delegated to a proper URL builder class, to not to repeat the logic in different places.
Steps to reproduce
Create a simple project using markdown & assetPrefix, and create a relative link in markdown.
Expected result
Link should still be relative, with assetPrefix not included anywhere.
Actual result
assetPrefix becomes part of the URL
Environment
System:
OS: Windows 10
CPU: (12) x64 Intel(R) Xeon(R) CPU E5-1650 0 @ 3.20GHz
Binaries:
Node: 12.6.0 - C:\Users\xivarsribes\scoop\apps\nodejs\current\node.EXE
npm: 6.9.0 - C:\Users\xivarsribes\scoop\apps\nodejs\current\npm.CMD
Languages:
Python: 3.5.4 - C:\Users\xivarsribes\scoop\apps\python35\current\python.EXE
Browsers:
Edge: 44.17763.1.0
npmPackages:
gatsby: ~2.9.4 => 2.9.11
gatsby-image: ^2.1.4 => 2.2.4
gatsby-plugin-manifest: ^2.1.1 => 2.2.1
gatsby-plugin-offline: ^2.1.3 => 2.2.1
gatsby-plugin-react-helmet: ^3.0.12 => 3.1.0
gatsby-plugin-sharp: ^2.1.5 => 2.2.2
gatsby-source-filesystem: ^2.0.39 => 2.1.2
gatsby-transformer-sharp: ^2.1.21 => 2.2.1
The text was updated successfully, but these errors were encountered: