We recently upgraded our dev servers from extlink 1.13 to 1.17, and we noticed that our exclusions under the Pattern Matching section were no longer working.

Our sites use settings similar to the following under Exclude links matching the pattern:
(unicorn\.example\.com)|(unicorn-qa\.example\.com)|(unicorn-dev\.example\.com)

Then this setting under Include links matching the pattern:
(example\.com)

Normally this would mark www.example.com and foobar.example.com as external links, but unicorn.external.com would not be marked. With the updated version, all unicorn.example.com links are marked as external links, both on the site and in the admin interface.

Comments

elachlan’s picture

This is the associated code:

if (url.indexOf('http') == 0
        && ((!url.match(internal_link) && !(extExclude && url.match(extExclude))) || (extInclude && url.match(extInclude)))
        && !(extCssExclude && $(this).parents(extCssExclude).length > 0)
        && !(extCssExplicit && $(this).parents(extCssExplicit).length < 1)) {
        external_links.push(this);
      }

Does the logic seem right to you?

notmike’s picture

This one fell off my radar for a little while. I compared the associated code with the same code from version 1.13. The logic was difficult to wrap my head around.

if (url.indexOf('http') == 0 
        && (!url.match(internal_link) || (extInclude && url.match(extInclude))) 
        && !(extExclude && url.match(extExclude)) 
        && !(extCssExclude && $(this).parents(extCssExclude).length > 0)
        && !(extCssExplicit && $(this).parents(extCssExplicit).length < 1)) {
        external_links.push(this);
      }

I should have a more concrete example for this one. I have a site at history.princeton.edu. I want all history.princeton.edu links to be internal, but all www.princeton.edu links and all politics.princeton.edu links (etc.) to be marked as external links. My "Include Links" has the pattern (princeton\.edu). My "Exclude links" has the pattern (history\.princeton\.edu).

With the earlier code, www.princeton.edu would match the Include links AND it does not match the Exclude links (true AND true), so it would correctly be marked as external. And history.princeton.edu does match the Include links but it does match the Exclude links (true AND false), so it would correctly not be marked as external.

With the new code, www.princeton.edu does not match the Exclude links OR it does match the Include links (true OR true), so it is correctly marked as external. However, history.princeton.edu does match the Exclude links OR it does match the Include links (false OR true), so it incorrectly marks it as external.

elachlan’s picture

If you can suggest an edit or a better approach it would be greatly appreciated.

We might have to update the code to make it more readable/understandable.

elachlan’s picture

Status: Active » Closed (cannot reproduce)