Skip to content

Commit

Permalink
Fix: Canary urls crashing (#3062)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElinorW authored Mar 26, 2024
1 parent 151f34a commit 53c97bb
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/app/utils/query-url-sanitization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/app/utils/resources/resources-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 53c97bb

Please sign in to comment.