Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gatsby transformer remark doesn't work with assetPrefix #15514

Closed
xavivars opened this issue Jul 8, 2019 · 0 comments · Fixed by #15518
Closed

Gatsby transformer remark doesn't work with assetPrefix #15514

xavivars opened this issue Jul 8, 2019 · 0 comments · Fixed by #15518

Comments

@xavivars
Copy link
Contributor

xavivars commented Jul 8, 2019

Description

Gatsby transformer remark doesn't work properly when used together with assetPrefix. The plugin was not modified with #12128

Before assetPrefix was introduced, all relative links where always prefixed with pathPrefix. After assetPrefix was introduced, links are prefixed either with pathPrefix or assetPrefix, 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 becomes https:/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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant