Skip to content

Commit a95a174

Browse files
committed
Fix default web app to deploy compatibility
1 parent d07437a commit a95a174

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/api/compatibility/CompatibleAzExtTreeDataProvider.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ export class CompatibleAzExtTreeDataProvider extends IntermediateCompatibleAzExt
4747
}
4848

4949
public override async findTreeItem<T>(fullId: string): Promise<T | undefined> {
50-
const result = await this.tdp.findItemById(fullId);
50+
// compatibility with default resource to deploy setting, which value might be a v1 tree item id
51+
const id = convertV1TreeItemId(fullId);
52+
const result = await this.tdp.findItemById(id);
5153
return isWrapper(result) ? result.unwrap<T>() : result as unknown as T;
5254
}
5355

@@ -100,3 +102,12 @@ class ShouldNeverBeCalledError extends Error {
100102
super(`${methodName} should never be called.`);
101103
}
102104
}
105+
106+
/**
107+
* Convert v1 tree item id to Azure resource id.
108+
*/
109+
export function convertV1TreeItemId(id: string): string {
110+
// if full id contains two instances of subscriptions/ then remove everything before the second instance
111+
const regex = /^(\/subscriptions.*)(?:\/subscriptions)/i;
112+
return id.replace(regex, '/subscriptions');
113+
}

0 commit comments

Comments
 (0)