fal-js/libs/client/src/utils.ts
Daniel Rochetti 9a0497da30
feat: client proxy + nextjs support (#9)
* feat(client): add function alias support

* feat(client): auto config from env vars

* fix(client): username in aliased url

* feat: nextjs proxy handler

* fix: update client tests

* feat(client): built-in queue support

* feat: client + nextjs e2e demo

* chore: update browserslist

* chore: update version info

* chore: update readme badges

* fix: ignore lint error on require
2023-09-11 16:26:06 -07:00

18 lines
361 B
TypeScript

export function isUUIDv4(id: string): boolean {
return (
typeof id === 'string' &&
id.length === 36 &&
id[14] === '4' &&
['8', '9', 'a', 'b'].includes(id[19])
);
}
export function isValidUrl(url: string) {
try {
const parsedUrl = new URL(url);
return parsedUrl.hostname.endsWith('fal.ai');
} catch (_) {
return false;
}
}