mirror of
https://github.com/uetchy/namae.git
synced 2025-08-20 01:48:12 +09:00
fix: properly validate URL
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
"dependencies": {
|
||||
"node-fetch": "^2.6.0",
|
||||
"npm-name": "^6.0.0",
|
||||
"validator": "^13.1.0",
|
||||
"whois-json": "^2.0.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import isURL from 'validator/lib/isURL';
|
||||
import {send, sendError, fetch, NowRequest, NowResponse} from '../util/http';
|
||||
|
||||
export default async function handler(
|
||||
@@ -10,12 +11,8 @@ export default async function handler(
|
||||
return sendError(res, new Error('no query given'));
|
||||
}
|
||||
|
||||
if (
|
||||
!/^[(http(s)?)://(www.)?a-zA-Z0-9@:%._+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_+.~#?&//=]*)$/.test(
|
||||
query,
|
||||
)
|
||||
) {
|
||||
return sendError(res, new Error('Invalid characters'));
|
||||
if (!isURL(query)) {
|
||||
return sendError(res, new Error('Invalid URL: ' + query));
|
||||
}
|
||||
|
||||
try {
|
||||
|
Reference in New Issue
Block a user