diff --git a/web/src/lib/clipboard.ts b/web/src/lib/clipboard.ts index 221d17ae..8c92f8b1 100644 --- a/web/src/lib/clipboard.ts +++ b/web/src/lib/clipboard.ts @@ -2,6 +2,8 @@ const allowedLinkTypes = new Set(["text/plain", "text/uri-list"]); export const pasteLinkFromClipboard = async () => { const clipboard = await navigator.clipboard.read(); + let pastedText = null; + if (clipboard?.length) { const clipboardItem = clipboard[0]; @@ -9,9 +11,20 @@ export const pasteLinkFromClipboard = async () => { if (allowedLinkTypes.has(type)) { const blob = await clipboardItem.getType(type); const blobText = await blob.text(); + try { + new URL(blobText); + pastedText = blobText; + break; + } catch (e) { + console.warn(`Content '${blobText}' is not a valid URL.`); + } - return blobText; } } + if(pastedText){ + return pastedText; + } } } + + diff --git a/web/tsconfig.json b/web/tsconfig.json index 3ee0d63e..300f1408 100644 --- a/web/tsconfig.json +++ b/web/tsconfig.json @@ -1,21 +1,17 @@ { - "extends": "./.svelte-kit/tsconfig.json", - "compilerOptions": { - "allowJs": true, - "checkJs": true, - "esModuleInterop": true, - "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true, - "skipLibCheck": true, - "sourceMap": true, - "strict": true, - "moduleResolution": "bundler", - "types": ["turnstile-types"], - "lib": ["WebWorker"] - } - // Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias - // except $lib which is handled by https://kit.svelte.dev/docs/configuration#files - // - // If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes - // from the referenced tsconfig.json - TypeScript does not merge them in + "extends": "./.svelte-kit/tsconfig.json", + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "resolveJsonModule": true, + "skipLibCheck": true, + "sourceMap": true, + "strict": true, + "module": "esnext", + "moduleResolution": "bundler", + "types": ["turnstile-types"], + "lib": ["WebWorker"] + } }