Skip to content
This repository has been archived by the owner on Apr 20, 2021. It is now read-only.

fix: relative urls inside html content to include prefix #328

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

henrikwirth
Copy link

Issue: #310

So when using pathPrefix, relativeUrls inside html don't get prefixed. This doesn't make much sense, since I might want to create content in WordPress with relative URLs that don't use the prefix yet, so later I can change the prefix to whatever I want.

Where this comes in handy and was really necessary, is a multisite setup with multiple translations.

What this fix does: When pathPrefix is used and the pluginOption.prefixRelativeUrls is active, the nodeStrings will be searched for elements, that start with href= and include a url that starts with /.

Excluded by the regex are urls that start with: pathPrefix|/wp-content|/wp-admin|/wp-includes|//

So we don't want prefix already prefixed URLs or URLs that start with a double //.

The other branch that was branched from v1.7.9 can be found here since I need a v1.7.10: https://github.com/henrikwirth/gatsby-source-wordpress-experimental/tree/fix-relative-urls-in-html

@henrikwirth
Copy link
Author

Maybe I could leave /wp-content|/wp-admin|/wp-includes outside of the regex, since we are not looking for wpUrl in that regex.

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

Successfully merging this pull request may close these issues.

1 participant