mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
* chore: add eslint-plugin-regexp * chore: autofix * chore: fix no-useless-flag * chore: fix optimal-lookaround-quantifier * chore: fix no-lazy-ends * chore: fix no-contradiction-with-assertion * chore: fix no-useless-assertions * chore: fix no-useless-quantifier * chore: fix remaining regexp issues * fix: regex for WFU news link validation
15 lines
349 B
TypeScript
15 lines
349 B
TypeScript
/**
|
|
* Check if a sub-domain is valid
|
|
* @param {String} hostname sub-domain
|
|
* @returns {Boolean} true if valid
|
|
*/
|
|
const isValidHost = (hostname?: string) => {
|
|
if (typeof hostname !== 'string') {
|
|
return false;
|
|
}
|
|
const regex = /^[\dA-Z](?:[\dA-Z-]{0,61}[\dA-Z])?$/i;
|
|
return regex.test(hostname);
|
|
};
|
|
|
|
export { isValidHost };
|