Skip to content

Commit 51604d8

Browse files
Merge pull request #299582 from Harikrishnan-M-B/patch-38
substring extraction behaviour
2 parents db2dc00 + 3d5d256 commit 51604d8

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

articles/frontdoor/rule-set-server-variables.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ When you use [Rule set match conditions](rules-match-conditions.md), server vari
1818
When you use [Rule set actions](front-door-rules-engine-actions.md), you can use server variables to dynamically change the request and response headers, and rewrite URLs, paths, and query strings, for example, when a new page load or when a form gets posted.
1919

2020
> [!NOTE]
21-
> Server variables are available with Azure Front Door Standard and Premium tiers.
21+
> Server variables are only available with Azure Front Door Standard and Premium tiers.
2222
2323
## Supported variables
2424

@@ -53,6 +53,25 @@ When you work with Rule Set actions, specify server variables by using the follo
5353
* Offsets and lengths within range: `{var:0:5}` = `AppId`, `{var:7:7}` = `1f59297`, `{var:7:-7}` = `1f592979c584d0f9d679db3e`
5454
* Zero lengths: `{var:0:0}` = null, `{var:4:0}` = null
5555
* Offsets within range and lengths out of range: `{var:0:100}` = `AppId=01f592979c584d0f9d679db3e66a3e5e`, `{var:5:100}` = `=01f592979c584d0f9d679db3e66a3e5e`, `{var:0:-48}` = null, `{var:4:-48}` = null
56+
* To experiment with how {variable:offset:length} works, open a Linux bash terminal or use bash terminal in [Azure Cloud Shell](https://shell.azure.com/). Enter the following example into the terminal and examine the output to understand how the substring extraction behaves.
57+
58+
```azurecli-interactive
59+
variable=helloworld123; echo ${variable:5} #Output = world123
60+
```
61+
```azurecli-interactive
62+
variable=helloworld123; echo ${variable:0:5} #Output = hello
63+
```
64+
> [!NOTE]
65+
> In Bash, a space is required before a negative number in parameter expansion to avoid syntax errors.
66+
67+
```azurecli-interactive
68+
variable=helloworld123; echo ${variable: -3:3} #Output=123
69+
```
70+
71+
```azurecli-interactive
72+
variable=helloworld123; echo ${variable:5: -3} #Output = world
73+
```
74+
5675
* `{url_path:seg#}`: Allow users to capture and use the desired URL path segment in URL Redirect, URL Rewrite, or any meaningful action. User can also capture multiple segments by using the same style as substring capture `{url_path:seg1:3}`. For example, for a source pattern `/id/12345/default` and a URL rewrite Destination `/{url_path:seg1}/home`, the expected URL path after rewrite is `/12345/home`. For a multiple-segment capture, when the source pattern is `/id/12345/default/location/test`, a URL rewrite destination `/{url_path:seg1:3}/home` results in `/12345/default/location/home`. Segment capture includes the location path, so if route is `/match/*`, segment 0 will be match.
5776

5877
Offset corresponds to the index of the start segment, and length refers to how many segments to capture, including the one at index = offset.

0 commit comments

Comments
 (0)