Skip to content

Commit a984002

Browse files
authored
Added negative lookahead to getResourceName regex (#2122)
1 parent e985668 commit a984002

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ 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}\/(.*)`);
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 )
1111
const matches = regexp.exec(fullId);
1212

1313
if (matches && matches.length > 1) {

0 commit comments

Comments
 (0)