absolutify icon indicating copy to clipboard operation
absolutify copied to clipboard

Valid targets

Open pex opened this issue 8 years ago • 4 comments

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 avatar Nov 08 '16 14:11 pex

@pex Good catch, www.foo.com and google.com should be treated as relative, the // URL is valid though.

sorensen avatar Nov 08 '16 17:11 sorensen

@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.

sorensen avatar Nov 15 '16 01:11 sorensen

Hej @sorensen I'm already glad you follow this up! Thanks for your help.

pex avatar Nov 15 '16 10:11 pex

@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?

sorensen avatar Dec 25 '16 19:12 sorensen