mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 07:03:25 +00:00
22 lines
525 B
TypeScript
22 lines
525 B
TypeScript
import type Collection from '#models/collection';
|
|
|
|
export const appendCollectionId = (
|
|
url: string,
|
|
collectionId?: Collection['id']
|
|
) => `${url}${collectionId && `?collectionId=${collectionId}`}}`;
|
|
|
|
export const appendResourceId = (url: string, resourceId?: string) =>
|
|
`${url}${resourceId && `/${resourceId}`}}`;
|
|
|
|
export function isValidHttpUrl(urlParam: string) {
|
|
let url;
|
|
|
|
try {
|
|
url = new URL(urlParam);
|
|
} catch (_) {
|
|
return false;
|
|
}
|
|
|
|
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
}
|