From 67c3c38f6ce8d50b7fe2025d8a235052aedde695 Mon Sep 17 00:00:00 2001 From: Theo Truong Date: Mon, 18 Nov 2024 15:41:31 -0700 Subject: [PATCH] Fixed path component filter JS considers `''` to be false. Updating the filter to include blank strings. Signed-off-by: Theo Truong --- api_generator/src/spec_parser/ApiPath.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api_generator/src/spec_parser/ApiPath.ts b/api_generator/src/spec_parser/ApiPath.ts index 308d3ca3c..57736dbbd 100644 --- a/api_generator/src/spec_parser/ApiPath.ts +++ b/api_generator/src/spec_parser/ApiPath.ts @@ -62,13 +62,13 @@ export default class ApiPath { }).join(' + ') } - // turn ['one', a, b, 'two/three', c] into `['/one', a, b, 'two/three', c].filter(c => c).join('/')` - // turn [a, b, 'one', c] into `['', a, b, 'one', c].filter(c => c).join('/')` + // turn ['one', a, b, 'two/three', c] into `['/one', a, b, 'two/three', c].filter(c => c != null).join('/')` + // turn [a, b, 'one', c] into `['', a, b, 'one', c].filter(c => c != null).join('/')` #build_optional (): string { const components = _.clone(this.components) if (components[0].startsWith("'")) components[0] = `'/${components[0].slice(1)}` else components.unshift("''") - return `[${components.join(', ')}].filter(c => c).join('/')` + return `[${components.join(', ')}].filter(c => c != null).join('/')` } // turn '/one/{a}/{b}/two/three/{c}' into ['one', a, b, 'two/three', c]