This is a bit weird. After updating from extlink-7.x-1.18 to extlink-7.x-1.19 the external link icon did not show on all external links, but on some. Reverting back to the previous version solved the issue.

[EDIT] the previous version mentioned CKEditor as a possible contributor, however that has been removed as it is not related to the cause and is a little distracting from the actual issue.

CommentFileSizeAuthor
#8 2962335-8.patch685 byteselachlan

Comments

ecvandenberg created an issue. See original summary.

elachlan’s picture

Just to be a bit more specific. Do ALL links stop getting the extlink icon? Also do you have any errors in the console?

camerongreen’s picture

I just installed this module, seems only some links work, others don't.

I've tried some tests, there seems to be a pattern.

It never seems to work on domains like example.org.au, example.com.au (seems to be baised against Australian domains :).

Also some other domains it seems to fail on http://www.aussiepigs.com/lucent, but http://www.example.com/lucent will work fine (More evidence of anti australianism!).

Just to finally prove this clear discrimination:

www.auspigs.com - doesn't work
www.usapigs.com - does work!

Clearly some sort anti-aussie conspiracy here.

elachlan’s picture

Can you post the html in a code block here? Also what are your settings and did you receive errors in your console?

ecvandenberg’s picture

I now see a pattern. Hyperlinks to the extensions .com .org or .de work fine. But the extension .nl does not. A hyperlink to www.domain.com gets the icon. A hyperlink to www.domain.nl does not.

When I look at the HTML source in Firefox it looks like:

<p><a href="http://www.whatever.com">www.whatever.com</a></p>
<p><a href="http://www.domain.org">www.domain.org</a></p>
<p><a href="http://www.domain.nl">www.domain.nl</a></p>
<p><a href="http://www.domain.de">www.domain.de</a></p>

And when I look at it with Firefox inspector it looks like:

<p><a href="http://www.whatever.com" class="ext" target="_blank" rel=" noopener noreferrer">www.whatever.com<span class="ext"><span class="element-invisible">(externe link)</span></span></a></p>
<p><a href="http://www.domain.org" class="ext" target="_blank" rel=" noopener noreferrer">www.domain.org<span class="ext"><span class="element-invisible">(externe link)</span></span></a></p>
<p><a href="http://www.domain.nl">www.domain.nl</a></p>
<p><a href="http://www.domain.de" class="ext" target="_blank" rel=" noopener noreferrer">www.domain.de<span class="ext"><span class="element-invisible">(externe link)</span></span></a></p>
elachlan’s picture

Are any of you using any css exclude, regex exclude, or "Exclude links with the same primary domain."?

camerongreen’s picture

I just installed the module and maybe turned on open links in a new window, nothing else. Exclude links with the same primary domain is checked, but I don't recall checking it, think it was turned on by default.

Hmm, so I think you could be on to something though, I just turned it off and all the links work. So something askew there.

elachlan’s picture

Version: 7.x-1.19 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new685 bytes

Can you apply this patch and see if it fixes the problem?

ecvandenberg’s picture

Yes it does! And switching on and off the function "Exclude links with the same primary domain." works also.

Thanks for your quick response.

  • elachlan committed b9789c1 on 7.x-1.x
    Issue #2962335 by elachlan: External link icon not always shown after...
elachlan’s picture

Status: Needs review » Fixed

Thanks. I'll do a release soon.

rooby’s picture

Priority: Normal » Major
Status: Fixed » Active

As I originally reported in #2961407: Regressions in 1.19?, I think version 1.20 still isn't working correctly.

One of my main problems was that I was testing on a temporary domain where the site is actually on a sub-domain and I was getting confusing results.
That aside though, the regex looks strange to me.

It would be useful to have some comments in the code stating what the different blocks of regex are trying to match, eg. domain name, port, file extension, etc.
It would make it much easier for a new developer to come in and do work on the code.

The current version has this:

    var pattern = /^(([^\/:]+?\.)*)([^\.:]{1,})((\.[a-z0-9]{1,253})*)(:[0-9]{1,5})?$/;
    var host = window.location.host.replace(pattern, '$2$3');
    var subdomain = window.location.host.replace(host, '');

So if my page is at website.gov.au/some/path then I get this

  • $0 = website.gov.au
  • $1 = website.gov.
  • $2 = gov.
  • $3 = au
  • $4 =

So host ends up being gov.au and the subdomain is empty, which is wrong.

If my page is at www.website.gov.au/some/path then I get this:

So host ends up being gov.au and the subdomain is empty, which is wrong.

If you go back to 1.18 you have this:

  var pattern = /^(([^\/:]+?\.)*)([^\.:]{4,})((\.[a-z]{1,4})*)(:[0-9]{1,5})?$/;
  var host = window.location.host.replace(pattern, '$3$4');
  var subdomain = window.location.host.replace(pattern, '$1');

So if my page is at website.gov.au/some/path then I get this

  • $0 = website.gov.au
  • $1 =
  • $2 =
  • $3 = website
  • $4 = .gov.au
  • $5 = .au

So host ends up being website.gov.au and the subdomain ends up being empty, which is correct.

If my page is at www.website.gov.au/some/path then I get this:

  • $0 = website.gov.au
  • $1 = www.
  • $2 = www.
  • $3 = website
  • $4 = .gov.au
  • $5 = .au

So host ends up being website.gov.au and the subdomain ends up being www, which is correct.

rooby’s picture

Issue summary: View changes
elachlan’s picture

Status: Active » Closed (duplicate)

Thanks for your input. Please see the discussion at #2914838: (Sub-)domain detection not reliable..

rooby’s picture

PS...
The issue where this bug was introduced was #2679977: New top level domains and pattern matching

The commit was: https://cgit.drupalcode.org/extlink/commit/?id=d6ab635

Will need to do a bit more work on the regex to fix both issues I assume.

If that's not trivial, the quick temporary fix would be to revert that commit, since it is worse with that commit for most (maybe all?) production use cases.