1
0
mirror of https://github.com/uetchy/namae.git synced 2025-08-20 18:08:11 +09:00

chore: capitalize error message

This commit is contained in:
2019-12-10 18:33:39 +09:00
parent 5c4f9959f1
commit 8ecfb3919a
12 changed files with 46 additions and 26 deletions

View File

@@ -1,23 +1,21 @@
import {send, sendError, fetch, NowRequest, NowResponse} from '../util/http';
import nodeFetch from 'node-fetch'
import nodeFetch from 'node-fetch';
export default async function handler(req: NowRequest, res: NowResponse) {
const {query} = req.query;
if (!query) {
return sendError(res, new Error('no query given'));
return sendError(res, new Error('No query given'));
}
if (
/[^\w-]/.test(
query,
)
) {
return sendError(res, new Error('invalid characters'));
if (/[^a-zA-Z0-9_-]/.test(query)) {
return sendError(res, new Error('Invalid characters'));
}
try {
const response = await nodeFetch(`https://gitlab.com/${query}`, {redirect: 'manual'});
const response = await nodeFetch(`https://gitlab.com/${query}`, {
redirect: 'manual',
});
const availability = response.status === 302;
send(res, {availability});
} catch (err) {