From 53c97bb2a5a6f0feb1b77efb53f841b61efef004 Mon Sep 17 00:00:00 2001 From: Elinor Date: Tue, 26 Mar 2024 15:25:19 +0300 Subject: [PATCH] Fix: Canary urls crashing (#3062) --- src/app/utils/query-url-sanitization.ts | 3 +-- src/app/utils/resources/resources-filter.ts | 2 +- .../query-input/auto-complete/suffix/documentation.ts | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/app/utils/query-url-sanitization.ts b/src/app/utils/query-url-sanitization.ts index 1d74b56de..8e07d5b72 100644 --- a/src/app/utils/query-url-sanitization.ts +++ b/src/app/utils/query-url-sanitization.ts @@ -102,14 +102,13 @@ function sanitizedQueryUrl(url: string): string { * @param segment */ function sanitizePathSegment(previousSegment: string, segment: string): string { - const segmentsToIgnore = ['$value', '$count', '$ref', '$batch']; if ( isAllAlpha(segment) || isAlphaNumeric(segment) || isDeprecation(segment) || SANITIZED_ITEM_PATH_REGEX.test(segment) || - segmentsToIgnore.includes(segment.toLowerCase()) || + segment.startsWith('$') || ENTITY_NAME_REGEX.test(segment) ) { return segment; diff --git a/src/app/utils/resources/resources-filter.ts b/src/app/utils/resources/resources-filter.ts index 03e182c2a..a30f0f18e 100644 --- a/src/app/utils/resources/resources-filter.ts +++ b/src/app/utils/resources/resources-filter.ts @@ -24,7 +24,7 @@ function getMatchingResourceForUrl(url: string, resources: IResource[]): IResour let matching = [...resources]; let node; for (const path of parts) { - if (hasPlaceHolders(path)) { + if (hasPlaceHolders(path) && path !== '{undefined-id}') { node = matching.find(k => hasPlaceHolders(k.segment)); matching = node?.children || []; } else { diff --git a/src/app/views/query-runner/query-input/auto-complete/suffix/documentation.ts b/src/app/views/query-runner/query-input/auto-complete/suffix/documentation.ts index 605d8d97f..162381e76 100644 --- a/src/app/views/query-runner/query-input/auto-complete/suffix/documentation.ts +++ b/src/app/views/query-runner/query-input/auto-complete/suffix/documentation.ts @@ -69,7 +69,7 @@ class DocumentationService implements IDocumentationService { if (matchingResource && matchingResource.labels.length > 0) { const currentLabel = matchingResource.labels.filter(k => k.name === this.queryVersion)[0]; - const method = currentLabel.methods[0]; + const method = currentLabel?.methods[0]; if (typeof method === 'string') { return null; }