Thanks for sharing, I just do the same with an improved code on a similar topic, because origin.indexOf(domain) === -1
can be bypassed.
If your domain is
example.com
, a malicious link tobadexample.com
would match becauseindexOf
finds the substring and returns a position (not -1)
I want my external links to open in a new tab - #66 by satonotdead
Perhaps the topics can be merged mixing the different techniques and detailing their pro/cons.