From f89bf27f5a8704bbaa48024ad7b5a4647a2d5813 Mon Sep 17 00:00:00 2001 From: Daniel Ruf <827205+DanielRuf@users.noreply.github.com> Date: Fri, 3 Jan 2020 23:57:21 +0100 Subject: [PATCH] fix: prevent issue with leading hyphen in package name - fixes #1429 (#1636) --- src/api/middleware.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/api/middleware.ts b/src/api/middleware.ts index 98067a854..f9e62bf65 100644 --- a/src/api/middleware.ts +++ b/src/api/middleware.ts @@ -33,7 +33,7 @@ export function setSecurityWebHeaders(req: $RequestExtend, res: $ResponseExtend, // flow: express does not match properly // flow info https://github.com/flowtype/flow-typed/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+express export function validateName(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer, value: string, name: string): void { - if (value.charAt(0) === '-') { + if (value === '-') { // special case in couchdb usually next('route'); } else if (utilValidateName(value)) { @@ -46,7 +46,7 @@ export function validateName(req: $RequestExtend, res: $ResponseExtend, next: $N // flow: express does not match properly // flow info https://github.com/flowtype/flow-typed/issues?utf8=%E2%9C%93&q=is%3Aissue+is%3Aopen+express export function validatePackage(req: $RequestExtend, res: $ResponseExtend, next: $NextFunctionVer, value: string, name: string): void { - if (value.charAt(0) === '-') { + if (value === '-') { // special case in couchdb usually next('route'); } else if (utilValidatePackage(value)) {