Skip to content

Commit

Permalink
fixed regex that extracts resource name (#2205)
Browse files Browse the repository at this point in the history
  • Loading branch information
malincrist committed Jun 20, 2023
1 parent 2805ab9 commit f299905
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { NameValuePair } from "./contracts/nameValuePair";

export class Utils {
public static getResourceName(resource: string, fullId: string, resultType: string = "name"): string {
const regexp = new RegExp(`\/${resource}\/(?!${resource})(.*)`); // negative lookahead to escape cases when "resource" is in "fullId" multiple times in a row (e.g. ...apis/operations/operations/foo - https://github.com/Azure/api-management-developer-portal/issues/2112 )
const matches = regexp.exec(fullId);
const regexp = new RegExp(`\/${resource}\/((?!${resource}\/).*)`);// negative lookahead to escape cases when "resource" is in "fullId" multiple times in a row (e.g. ...apis/operations/operations/foo - https://github.com/Azure/api-management-developer-portal/issues/2112 )
const matches = regexp.exec(fullId);

if (matches && matches.length > 1) {
switch (resultType) {
Expand Down

0 comments on commit f299905

Please sign in to comment.