mirror of
https://github.com/Bubka/2FAuth.git
synced 2025-08-09 13:55:01 +02:00
Set up the Webauthn service to handle webauthn login & registration
This commit is contained in:
15
resources/js_vue3/services/webauthn/isValidDomain.js
vendored
Normal file
15
resources/js_vue3/services/webauthn/isValidDomain.js
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* A simple test to determine if a hostname is a properly-formatted domain name
|
||||
*
|
||||
* A "valid domain" is defined here: https://url.spec.whatwg.org/#valid-domain
|
||||
*
|
||||
* Regex sourced from here:
|
||||
* https://www.oreilly.com/library/view/regular-expressions-cookbook/9781449327453/ch08s15.html
|
||||
*/
|
||||
export function isValidDomain(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)
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user