# A guide to encoding URLs

**URL:** https://community.stadium.software/community/t/a-guide-to-encoding-urls/196
**Category:** How To
**Created:** [December 15, 2022, 9:50am UTC](https://community.stadium.software/community/t/a-guide-to-encoding-urls/196 "2022-12-15T09:50:30Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![shamima](https://community.stadium.software/community/user_avatar/community.stadium.software/shamima/32/268_2.png) [@shamima](https://community.stadium.software/community/u/shamima)
#### Post date: [December 15, 2022, 9:50am UTC](https://community.stadium.software/community/t/a-guide-to-encoding-urls/196/1 "2022-12-15T09:50:30Z")

</div>

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](https://community.stadium.software/community/uploads/short-url/gsvAmL9oPvlCrkj3YaGMlF7fo8W.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

 ![image](https://community.stadium.software/community/uploads/default/original/1X/f814360d292cbfad11d44d0dae89b0e9a4372a34.png)

#### 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

 ![image](https://community.stadium.software/community/uploads/default/original/1X/08863b347b8bb4d26b12b0edd50402dcf3cf615a.png)

#### 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)}`

---

<div class="post-metadata">

### Author: ![shamima](https://community.stadium.software/community/user_avatar/community.stadium.software/shamima/32/268_2.png) [@shamima](https://community.stadium.software/community/u/shamima)
#### Post date: [December 15, 2022, 9:50am UTC](https://community.stadium.software/community/t/a-guide-to-encoding-urls/196/2 "2022-12-15T09:50:36Z")

</div>



---

<div class="post-metadata">

### Author: ![shamima](https://community.stadium.software/community/user_avatar/community.stadium.software/shamima/32/268_2.png) [@shamima](https://community.stadium.software/community/u/shamima)
#### Post date: [January 9, 2023, 9:06am UTC](https://community.stadium.software/community/t/a-guide-to-encoding-urls/196/3 "2023-01-09T09:06:04Z")

</div>


