From aa26698481a9c43054dca54bd01c3ce3bb6cd047 Mon Sep 17 00:00:00 2001 From: Matthew Oslan Date: Sat, 29 Jun 2019 13:10:22 -0400 Subject: [PATCH] Fix compatibility with earlier Node.js versions Named regex match groups are not supported until Node.js 10.0.0 --- routes/weather.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/routes/weather.ts b/routes/weather.ts index eeeb0ee..fe313e5 100644 --- a/routes/weather.ts +++ b/routes/weather.ts @@ -453,10 +453,13 @@ function getParameter( parameter: string | string[] ): string { * @throws Throws an error message if the string is in an invalid format and cannot be parsed. */ function parsePWS( pwsString: string): PWS { - const match = pwsString.match( /^pws:(?[a-f\d]{32})@(?[a-zA-Z\d]+)$/ ); + const match = pwsString.match( /^pws:([a-f\d]{32})@([a-zA-Z\d]+)$/ ); if ( !match ) { throw "Invalid PWS format."; } - return match.groups as PWS; + return { + apiKey: match[ 1 ], + id: match[ 2 ] + }; }