(Sub-)domain detection not reliable.

Created on 9 October 2017, over 7 years ago
Updated 10 July 2024, 9 months ago

We just launched a new site with a pretty short domain name (www.wwf.ch) and realised, that all internal links where opened in a new window.

When debugging I realised that the pattern for the external link detection is not really reliable. I made a js fiddle to demo a few cases with the regular expression from the current dev extlink.js:
https://jsfiddle.net/yqmgbbd0/6/

I copied the results here:

www.example.com => sub: www.example. , host: example.com
www.example.com:8080 => sub: www.example. , host: example.com
www.example.co.uk => sub: www.example.co. , host: co.uk
test.example.com => sub: test.example. , host: example.com
example.com => sub: example. , host: example.com

As you can see the subdomain and hostname are not reliable detected. As domain detection is pretty complicated i would recommend to use something like https://github.com/wrangr/psl.

On the other hand a workaround for the bug is relatively easy, as it is possible to set a internal domain name in the module config.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡¦πŸ‡ΉAustria nebel54 Vienna

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024