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

HTTPS issues with doRemoveHttpPrefixFromAttributes #6

Closed
highstrike opened this issue Nov 20, 2017 · 1 comment
Closed

HTTPS issues with doRemoveHttpPrefixFromAttributes #6

highstrike opened this issue Nov 20, 2017 · 1 comment

Comments

@highstrike
Copy link

highstrike commented Nov 20, 2017

Hey,

If doRemoveHttpPrefixFromAttributes is set to true (default)
and your current website protocol is https
and you have external links in your website without https

the links will break because the minifier will remove the http or https part of the link and only leave //

Example site where your library is deployed -- https://www.example.com
External link in website is -- http://www.mirror.com
After minify link is transformed into //www.mirror.com and when you click it it actually takes you to -- https://www.mirror.com
Therefore the link breaks because www.mirror.com is working only on http and is not responding on https.

Probably adding an extra condition (after the rel external and target _blank conditions) to check the current protocol against the protocol of the link (so proceed only if protocols match) will make this feature a lot safer.

Example:
on https protocol, link with https, remove the protocol and leave only //
on https protocol, link with http, don't remove the protocol because the link will break
on http protocol, link with http, remove the protocol and leave only //
on http protocol, link with https, don't remove the protocol because while some websites will redirect to https, others might not and the link will break

Thanks

PS: I know, I'm to blame for not using rel="external" on actual external links but sometimes I forget, okay? 😆

@Bilge
Copy link

Bilge commented Nov 23, 2017

I came here to post exactly this issue. The doRemoveHttpPrefixFromAttributes optimization is completely invalid because //example.com is not the same as http://example.com unless the page containing the link happens to be hosted on the same protocol. If the page is hosted on HTTPS, //example.com implies https://example.com, which is completely different and may not exist.

It is not sufficient to simply disable this by default, the optimization is fundamentally invalid and should be removed.

voku added a commit that referenced this issue Dec 2, 2017
-> now you can decide which URL shout use the function and it's disabled by default ...
@voku voku closed this as completed Dec 2, 2017
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

3 participants