diff options
author | Matthew Miller <matthew@millerti.me> | 2022-03-04 16:13:36 -0800 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2022-03-04 16:13:36 -0800 |
commit | 701fa108dad56d8a2ad9017210f96e6821d84e31 (patch) | |
tree | ced875752a6f4aaa7e91b02a962b97d2017ca22f /packages/browser/src | |
parent | 26dc995ee796a0ba3298d23dd2127f4c3b2dc40b (diff) |
Add localhost as an effective domain
Diffstat (limited to 'packages/browser/src')
-rw-r--r-- | packages/browser/src/helpers/isValidDomain.ts | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/packages/browser/src/helpers/isValidDomain.ts b/packages/browser/src/helpers/isValidDomain.ts index ee68818..2eb146f 100644 --- a/packages/browser/src/helpers/isValidDomain.ts +++ b/packages/browser/src/helpers/isValidDomain.ts @@ -7,5 +7,9 @@ * https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch08s15.html */ export function isValidDomain(hostname: string): boolean { - return /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(hostname); + return ( + // Consider localhost valid as well since it's okay wrt Secure Contexts + hostname === 'localhost' + || /^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(hostname) + ); } |