mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-03 10:38:03 +08:00
feat(config)!: unsafe domain toggle (#11588)
This commit is contained in:
16
lib/utils/valid-host.js
Normal file
16
lib/utils/valid-host.js
Normal 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,
|
||||
};
|
||||
Reference in New Issue
Block a user