Download src/utils.js from linuxrun/cors: direct link, hf CLI and curl.
- Browser
- Download file 329 Bytes
-
https://huggingface.co/spaces/linuxrun/cors/resolve/main/src/utils.js
- Command line
-
hf download hf://spaces/linuxrun/cors/src/utils.js
-
curl -L -o utils.js https://huggingface.co/spaces/linuxrun/cors/resolve/main/src/utils.js
329 Bytes
| import tldjs from "tldjs"; | |
| import net from "node:net"; | |
| /** | |
| * 判断主机名是否合法 | |
| * @param {string} hostname | |
| * @returns {boolean} | |
| */ | |
| export function isValidHostName(hostname) { | |
| if (!hostname) return false; | |
| if (net.isIPv4(hostname) || net.isIPv6(hostname)) return true; | |
| return tldjs.isValidHostname(hostname); | |
| } | |