url-regex-safe icon indicating copy to clipboard operation
url-regex-safe copied to clipboard

trailingPeriod setting not honored on subdomains

Open roger-obando opened this issue 4 years ago • 2 comments

Currently if I try to run urlRegexSafe on a string like 'http://www.google.com.' it will return 'http://www.google.com' as the first match but if I were to run it on 'http://www.google.com/subdir.' it will return 'http://www.google.com/subdir.' (trailing period included). Is this the intended functionality? How can I go about ensuring that trailing periods will always be ignored?

roger-obando avatar Oct 27 '21 20:10 roger-obando

I experience the same problem. Are there any plans to resolve this?

weckbach avatar Nov 23 '21 17:11 weckbach

PR welcome!

niftylettuce avatar Nov 23 '21 17:11 niftylettuce

I worked around this by adapting the path part from:

(?:[/?#][^\s")']*)?

to:

(?:[/?#][^\s")']*[^\s")'.?!])?

which is probably not quite right but seemed to cover all the cases I threw at it

birtles avatar Aug 03 '23 01:08 birtles

Can you submit a PR and maybe a test? @birtles would love to get this in

titanism avatar Aug 12 '23 21:08 titanism

Can you submit a PR and maybe a test? @birtles would love to get this in

Sure, I've submitted #29 for this.

birtles avatar Aug 14 '23 02:08 birtles

v4.0.0 released with this, thank you @birtles

release notes @ https://github.com/spamscanner/url-regex-safe/releases/tag/v4.0.0

note: this version now requires node v14+

titanism avatar Aug 15 '23 17:08 titanism

Thank you! 🙏

birtles avatar Aug 16 '23 02:08 birtles