Skip to content

Commit

Permalink
added input validation
Browse files Browse the repository at this point in the history
  • Loading branch information
aaanh committed Oct 24, 2022
1 parent ff0466a commit e3701f3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions workers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ const invalid = `<DOCTYPE html>
*/
async function handleRequest(request) {
const { searchParams } = new URL(request.url);
const regex = new RegExp('(https:\/\/)?gist.github.com\/[a-zA-Z0-9_\-]*\/([a-zA-Z0-9]*)');

let gist_url = searchParams.get('gist_url') ?? null;
let assert_url = regex.test(gist_url);

let gist_url = searchParams.get('gist_url') ?? null

console.log(gist_url)

if (gist_url == null || gist_url == '') {
if (gist_url == null || gist_url == '' || assert_url == false) {
return new Response(invalid, {
headers: {
'content-type': 'text/html;charset=UTF-8'
Expand Down

0 comments on commit e3701f3

Please sign in to comment.