absolutify
absolutify copied to clipboard
Valid targets
Currently the following strings won't be changed corresponding to the tests:
-
www.foo.com
-
google.com
-
http://www.bar.com
-
//baz.com
from test.js:
// Non-changing string, should not get replaced
var ok = ''
+ '<img src="www.foo.com" />'
+ '<img src="google.com" />'
+ '<img src="http://www.bar.com" />'
+ '<img src="//baz.com" />'
Though I think targets without protocol (or //
) are not valid URLs and should pass for being relative paths (in this test case this applies to www.foo.com
and google.com
).
AFAIK most browsers consider such targets as relative URLs, too.
@pex Good catch, www.foo.com
and google.com
should be treated as relative, the //
URL is valid though.
@pex Just following up, I'm still working on this, the primary issue I'm running into is that there doesn't seem to be a way to normalize if a url target begins with /
or not.
For example: html <a href="/some-article">Article</a> <a href="some-article">Article</a>
The only workaround I can currently think of is to run a final search/replace to convert any inputUrl//
to inputUrl/
Sorry for the delay on this, edge cases are giving me some grief.
Hej @sorensen I'm already glad you follow this up! Thanks for your help.
@pex So I apparently forgot to commit any code changes for this, but I think I have a working solution for you. Would you mind checking out the target-improvement branch and verifying?