mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-22 03:33:06 +08:00
fix(editor): prevent errors from isStrictUrl (#9419)
Closes: [BS-2277](https://linear.app/affine-design/issue/BS-2277/typeerror-failed-to-construct-url-invalid-url)
This commit is contained in:
@@ -130,14 +130,17 @@ function isCommonTLD(url: URL) {
|
|||||||
* Assuming the user will input anything, we need to check rigorously.
|
* Assuming the user will input anything, we need to check rigorously.
|
||||||
*/
|
*/
|
||||||
export function isStrictUrl(str: string) {
|
export function isStrictUrl(str: string) {
|
||||||
if (!isValidUrl(str)) {
|
try {
|
||||||
|
if (!isValidUrl(str)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = new URL(normalizeUrl(str));
|
||||||
|
|
||||||
|
return isCommonTLD(url);
|
||||||
|
} catch {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const url = new URL(normalizeUrl(str));
|
|
||||||
if (isCommonTLD(url)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isUrlInClipboard(clipboardData: DataTransfer) {
|
export function isUrlInClipboard(clipboardData: DataTransfer) {
|
||||||
|
|||||||
Reference in New Issue
Block a user