Skip to content

Allow variable substitution default value containing a colon - #882

Draft
Christian Grotheer (grthr) wants to merge 4 commits into
devcontainers:mainfrom
grthr:patch-1
Draft

Allow variable substitution default value containing a colon#882
Christian Grotheer (grthr) wants to merge 4 commits into
devcontainers:mainfrom
grthr:patch-1

Conversation

@grthr

@grthr Christian Grotheer (grthr) commented Aug 29, 2024

Copy link
Copy Markdown

Allows to use a default value like this:

 "WEBSITE_URL": "${localEnv:WEBSITE_URL:https://example.com"

@chrmarti Christof Marti (chrmarti) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. Left a comment with my thoughts.

// try to separate variable arguments from variable name
let args: string[] = [];
const parts = variable.split(':');
const parts = variable.split(':', 3);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would prevent us from introducing additional arguments in the future because we would break existing configs.

Also: split() with the limit argument does not include the remaining part of the text after the limit was hit. This would need a closer look.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we would need additional arguments in the future after the current ones it would be nice to be able to escape the : in the default value. Would this be an approach to go for?

something like "WEBSITE_URL": "${localEnv:WEBSITE_URL:https\://example.com"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants