We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 94b9e32 commit 9278cc0Copy full SHA for 9278cc0
1 file changed
package/validationUtil/checkHttpUrl/index.ts
@@ -1,12 +1,7 @@
1
export default function checkHttpUrl(str: string): boolean {
2
- const roughPattern = /^(https?:\/\/)/i;
3
-
4
- if (!roughPattern.test(str)) return false;
5
6
try {
7
- new URL(str);
8
9
- return true;
+ const url = new URL(str);
+ return url.protocol === "http:" || url.protocol === "https:";
10
} catch {
11
return false;
12
}
0 commit comments