Initially excluding the specifics of the regex, this code is:
if ( ! /.../.test(l.host) )
"if not regex.matches(l.host)" or "if l.host does not match this regex"
So, the regex must correctly describe the contents of l.host text for the conditional to fail and thus avoid throwing the error.
On to the regex itself:
This is checking for the existence of
tumblr but only after any string ending in
. that might exist:
^ # start of line
( # begin capturing group 1
.* # match any (non-newline) character, as many times as possible, but zero allowed
\. # match a literal .
) # end capturing group 1
? # make whole preceeding item optional
tumblr # match literal text tumblr
[^.]* # match any non . character, as many times as possible, but zero allowed
$ # match end of line
I thought it was testing to see if the host was tumblr
Yeah, it looked like it might be intended to check that, but if so it's the wrong way to do it.
For that, the first bit should be something like
^(?:[\w-]+\.)? to capture an alphanumeric subdomain (the
?: is a non-capturing group, the
[\w-]+ is at least 1 alphanumeric, underscore or hyphen) and the last bit should be either
\.(?:com|net|org)$ or perhaps like
(?:\.[a-zA-Z]+)+$ depending on how flexible the tld section might need to be.