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

relative links get full path prepended #198

Open
joyously opened this issue Oct 1, 2022 · 4 comments
Open

relative links get full path prepended #198

joyously opened this issue Oct 1, 2022 · 4 comments

Comments

@joyously
Copy link
Contributor

joyously commented Oct 1, 2022

I have some content with relative links. As this is an old site that has been transformed a couple times, I use a plugin to put .html on my page slugs. It works great (maintaining old site structure), and static-html-output plugin works fine with that.
However, for the existing relative links, the plugin transforms the link incorrectly.
The content contains a link like
<a href="collector2.html">E to H</a>
and the static page output has
<a href="http://example.com/folder/collector1.html/collector2.html">E to H</a>

I'm thinking that part of the code doesn't take into account that the current address might not be a folder, but a HTML file.
Where to look for this in the code?

@leonstafford
Copy link
Contributor

Hmm, interesting scenario.

I couldn't quickly find it, but I recall a "force fully qualified URLs" plugin for WP, which may be a simple workaround for your scenario.

If there's a more general issue with not supporting any relative URLs when publishing, that may require adding a failing unit/integration test here: https://github.com/leonstafford/static-html-output/blob/develop/tests/HTMLProcessorTest.php

Then we can try to fix things for that test without breaking other ones.

@joyously
Copy link
Contributor Author

joyously commented Oct 2, 2022

I don't understand what you are referring to, for the WP plugin forcing URLs, because this is content that WP is not involved with. It's just a link in the content, put in by the user, before I imported it into WP.
My goal is actually to get root relative links for everything, but this plugin is not really set up for that.
Also, the code uses parse_url a lot, and there is a note in the PHP manual that says it doesn't work for relative URLs.

@leonstafford
Copy link
Contributor

Hmm, good points. I think we'll still need to approach it with a failing test to prove what's broken, then work on a fix

@joyously
Copy link
Contributor Author

joyously commented Oct 3, 2022

I looked at your file of tests, but I don't understand what is needed to set up a test where the address of the current page is domain/folder/slug.html instead of domain/folder/slug/index.html and then the content has a plain relative link like slug2.html.

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

No branches or pull requests

2 participants