diff --git a/projects/laji-api-client-b/src/laji-api-client-b.service.ts b/projects/laji-api-client-b/src/laji-api-client-b.service.ts index 59951248d..142e39da6 100644 --- a/projects/laji-api-client-b/src/laji-api-client-b.service.ts +++ b/projects/laji-api-client-b/src/laji-api-client-b.service.ts @@ -43,13 +43,8 @@ const splitAndResolvePath = < M extends Method

, >(path: P, params?: Parameters): string[] => { // parse path into segments based on path parameters - // eg. "/person/{personToken}/profile" -> ["/person", "/{personToken}/profile"] - - // using a lookahead makes the split not consume the matching substrings - // but instead we are splitting *before* the pattern - // using a non-capturing group (?:...) avoids duplicates in the split output - // matches start with `/` such that there's a beginning `/` but no trailing `/` - const segments = path.split(/(?=(?:\/\{[^}]+\}))/); + // eg. "/person/{personToken}/profile" -> ["/person", "/{personToken}", "/profile"] + const segments = path.split(/(\/\{[^}]+\})/).filter(Boolean); if (!params) { return segments;