Skip to content

Commit 16c5c13

Browse files
Invoke-ADORestAPI: Fixing #111. No longer treating brackets in REST variables.
1 parent ee77c7b commit 16c5c13

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

Invoke-ADORestAPI.ps1

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,33 +157,28 @@ Specifies the method used for the web request. The acceptable values for this pa
157157
)
158158

159159
begin {
160+
# From [Irregular](https://github.com/StartAutomating/Irregular):
161+
# ?<REST_Variable> -VariableFormat Braces
160162
$RestVariable = [Regex]::new(@'
161-
# Matches URL segments and query strings containing variables.
162-
# Variables can be enclosed in brackets or curly braces, or preceeded by a $ or :
163163
(?> # A variable can be in a URL segment or subdomain
164164
(?<Start>[/\.]) # Match the <Start>ing slash|dot ...
165165
(?<IsOptional>\?)? # ... an optional ? (to indicate optional) ...
166166
(?:
167167
\{(?<Variable>\w+)\}| # ... A <Variable> name in {} OR
168-
\[(?<Variable>\w+)\]| # A <Variable> name in [] OR
169-
`\$(?<Variable>\w+) | # A `$ followed by a <Variable> OR
170-
\:(?<Variable>\w+) # A : followed by a <Variable>
171168
)
172169
|
173170
(?<IsOptional> # If it's optional it can also be
174171
[{\[](?<Start>/) # a bracket or brace, followed by a slash
175172
)
176173
(?<Variable>\w+)[}\]] # then a <Variable> name followed by } or ]
174+
177175
| # OR it can be in a query parameter:
178-
(?<Start>[?&]) # Match The <Start>ing ? or & ...
179-
(?<Query>[\w\-]+) # ... the <Query> parameter name ...
176+
(?<Start>[\?\&]) # Match The <Start>ing ? or & ...
177+
(?<Query>[\$\w\-]+) # ... the <Query> parameter name ...
180178
= # ... an equals ...
181179
(?<IsOptional>\?)? # ... an optional ? (to indicate optional) ...
182180
(?:
183181
\{(?<Variable>\w+)\}| # ... A <Variable> name in {} OR
184-
\[(?<Variable>\w+)\]| # A <Variable> name in [] OR
185-
\`$(?<Variable>\w+) | # A $ followed by a <Variable> OR
186-
\:(?<Variable>\w+) # A : followed by a <Variable>
187182
)
188183
)
189184
'@, 'IgnoreCase,IgnorePatternWhitespace')

0 commit comments

Comments
 (0)