From 8dfa429e227f543d85c2f74656e0bdda6b2cd799 Mon Sep 17 00:00:00 2001 From: leonnicolas Date: Sun, 29 Nov 2020 16:14:40 +0100 Subject: [PATCH] src/resolvers/*: use reg ex --- src/resolvers/cargoBikeResolver.ts | 4 ++-- src/resolvers/lendingStationResolvers.ts | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/resolvers/cargoBikeResolver.ts b/src/resolvers/cargoBikeResolver.ts index 27542dd..b90b372 100644 --- a/src/resolvers/cargoBikeResolver.ts +++ b/src/resolvers/cargoBikeResolver.ts @@ -163,10 +163,10 @@ export default { }, NumRange: { min: (parent: string) => { - return parent.split(',')[0].replace('[', ''); + return parent.replace(/^\[(.*),.*]$/, '$1'); }, max: (parent: string) => { - return parent.split(',')[1].replace(']', ''); + return parent.replace(/^\[.*,(.*)]$/, '$1'); } }, Equipment: { diff --git a/src/resolvers/lendingStationResolvers.ts b/src/resolvers/lendingStationResolvers.ts index f17d87f..91d25bb 100644 --- a/src/resolvers/lendingStationResolvers.ts +++ b/src/resolvers/lendingStationResolvers.ts @@ -106,11 +106,10 @@ export default { }, DateRange: { from (parent: string) { - return parent.split(',')[0].replace('[', ''); + return parent.replace(/^\[(.*),.*\)$/, '$1'); }, to (parent: string) { - const str = parent.split(',')[1].replace(')', ''); - return (str.length > 0) ? str : null; + return parent.replace(/^\[.*,(.*)\)$/, '$1'); } }, TimeFrame: {