Files
ncd-fe/packages/nicolium/src/utils/auth.ts
nicole mikołajczyk 4e739e0b28 nicolium: auth refactoring before the actually good changes
Signed-off-by: nicole mikołajczyk <git@mkljczk.pl>
2026-03-15 21:37:07 +01:00

24 lines
480 B
TypeScript

const validId = (id?: string | null | false) =>
typeof id === 'string' && id !== 'null' && id !== 'undefined';
const isURL = (url?: string | null) => {
if (typeof url !== 'string') return false;
try {
new URL(url);
return true;
} catch {
return false;
}
};
const parseBaseURL = (url?: string) => {
if (typeof url !== 'string') return '';
try {
return new URL(url).origin;
} catch {
return '';
}
};
export { validId, isURL, parseBaseURL };