Skip to content

Commit f299905

Browse files
authored
fixed regex that extracts resource name (#2205)
1 parent 2805ab9 commit f299905

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { NameValuePair } from "./contracts/nameValuePair";
77

88
export class Utils {
99
public static getResourceName(resource: string, fullId: string, resultType: string = "name"): string {
10-
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 )
11-
const matches = regexp.exec(fullId);
10+
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 )
11+
const matches = regexp.exec(fullId);
1212

1313
if (matches && matches.length > 1) {
1414
switch (resultType) {

0 commit comments

Comments
 (0)