feat(config)!: unsafe domain toggle (#11588)

This commit is contained in:
Tony
2023-01-10 11:45:05 +00:00
committed by GitHub
parent ab2f61824d
commit a66cbcf6ee
66 changed files with 338 additions and 15 deletions

16
lib/utils/valid-host.js Normal file
View File

@@ -0,0 +1,16 @@
/**
* Check if a sub-domain is valid
* @param {String} hostname sub-domain
* @returns {Boolean} true if valid
*/
const isValidHost = (hostname) => {
if (typeof hostname !== 'string') {
return false;
}
const regex = /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/;
return regex.test(hostname);
};
module.exports = {
isValidHost,
};