Skip to content

Commit 9beae23

Browse files
authored
Update logic to valid env in repository url (#540)
* Update logic to valid env in repository url * Update version * Update Co-authored-by: rentu <[email protected]>
1 parent 9003076 commit 9beae23

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "azure-iot-edge",
33
"displayName": "Azure IoT Edge",
44
"description": "This extension is now a part of Azure IoT Tools extension pack. We highly recommend installing Azure IoT Tools to get full capabilities for Azure IoT development. Develop, deploy, debug, and manage your IoT Edge solution.",
5-
"version": "1.21.0-rc1",
5+
"version": "1.21.0-rc2",
66
"publisher": "vsciot-vscode",
77
"aiKey": "95b20d64-f54f-4de3-8ad5-165a75a6c6fe",
88
"icon": "logo.png",

src/common/utility.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export class Utility {
160160
}
161161

162162
public static expandEnv(input: string, overrideKVs: {[name: string]: string} = {}, ...exceptKeys: string[]): string {
163-
const pattern: RegExp = new RegExp(/\$([a-zA-Z0-9_]+)|\${([a-zA-Z0-9_]+)}/g);
163+
const pattern: RegExp = new RegExp(/\$(\w+)|\${(\w+)}/g);
164164
const exceptSet: Set<string> = new Set(exceptKeys);
165165
if (!overrideKVs) {
166166
overrideKVs = {};
@@ -586,20 +586,25 @@ export class Utility {
586586
hostName = null;
587587
}
588588

589-
if (hostName && /[^a-zA-Z0-9\.\-:\${}]/.test(hostName)) {
590-
return "Repository host name can only contain alphanumeric characters or .-:, and ${} are also supported for environment variables";
589+
if (hostName) {
590+
const hostNameWithoutEnv = hostName.replace(/\$\w+|\${\w+}/g, "");
591+
if (/[^\w.-:]/.test(hostNameWithoutEnv)) {
592+
return "Repository host name can only contain alphanumeric characters or .-:, and ${} are also supported for environment variables";
593+
}
591594
}
592595

593-
if (/[^a-z0-9\._\-\/\${}]+/.test(repositoryName)) {
596+
const repositoryNameWithoutEnv = repositoryName.replace(/\$\w+|\${\w+}/g, "");
597+
if (/[^a-z0-9._\-\/]+/.test(repositoryNameWithoutEnv)) {
594598
return "Repository name can only contain lowercase letters, digits or ._-/, and ${} are also supported for environment variables";
595599
}
596600

597601
if (tag) {
598-
if (tag.length > 128) {
602+
const tagWithoutEnv = tag.replace(/\$\w+|\${\w+}/g, "");
603+
if (tagWithoutEnv.length > 128) {
599604
return "The maximum length of tag is 128";
600605
}
601606

602-
if (/[^a-zA-Z0-9\._\-\${}]+/.test(tag)) {
607+
if (/[^\w.-]+/.test(tagWithoutEnv)) {
603608
return "Tag can only contain alphanumeric characters or ._-, and ${} are also supported for environment variables";
604609
}
605610
}

0 commit comments

Comments
 (0)