A guide to encoding URLs

URLs are not encoded by default in Stadium. The following explanations will help you to choose the right encoding functions to encode URLs in Stadium.


Sample
Encodesample.sapz (8.4 KB)


Note: In the examples below, we assume that none of the data has been encoded prior to encoding. Be careful to check that you are not encoding data that are already encoded.


Scenario 1: Encoding querystring parameter values in NavigateToPage Action

The encodeURIComponent() function is used to encode path, query string, fragment, etc

Use encodeURIComponent() to encode querystring parameter values in Navigate To Page Action
Example in ButtonClick script in attached solution

Scenario 2: Encoding data that are full URL from database or any other source that is assigned to variables

Use encodeURI to encode these variables
Example in EncodeFullUrl.Load script in the attached solution

Scenario 3: Encoding data containing full URL and query string

If you have to encode data that contains a combination of querystring parameter values and full URL, each value should be encoded separately

Example in EncodeMixData.Load in the attached solution

= ${encodeURI(~.FullURLVariable)}?parameter=${encodeURIComponent(Parameters.parameter)}