decentralised sync engine

feat: string is domain helper

serenity 9d5f1c15 95e37b07

Changed files
+12
src
lib
utils
+12
src/lib/utils/domains.ts
···
···
+
/**
+
* Checks if a string is a domain
+
* does NOT do TLD-level checks. Any domain/NSID-like string will pass this check
+
*/
+
export const isDomain = (str: string) => {
+
try {
+
const url = new URL(str.includes("://") ? str : `https://${str}`);
+
return url.hostname.includes(".") && !url.hostname.startsWith(".");
+
} catch {
+
return false;
+
}
+
};