elementor / static-html-output

Static HTML Output Plugin for WordPress

Home Page:https://statichtmloutput.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

relative links get full path prepended

joyously opened this issue · comments

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?

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.

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.

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

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.