# Decode URL in expression for View component

**URL:** <https://forum.inductiveautomation.com/t/decode-url-in-expression-for-view-component/18676>\
**Category:** Ignition\
**Created:** [June 29, 2018, 9:01pm UTC](https://forum.inductiveautomation.com/t/decode-url-in-expression-for-view-component/18676 "2018-06-29T21:01:39Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimjohnson](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@jimjohnson](https://forum.inductiveautomation.com/u/jimjohnson)\
**Post date:** [June 29, 2018, 9:01pm UTC](https://forum.inductiveautomation.com/t/decode-url-in-expression-for-view-component/18676/1 "2018-06-29T21:01:39Z")

</div>

I am getting a tag which contains a URL which has been encoded or changed to the form with %xx, for example:

http%3a%2f%[2ftestsitportal.johndoe.net](http://2ftestsitportal.johndoe.net)%2fEWIPortal%2fPortalPage%2f%2fCEWIViewer.aspx

Is there a way to do an “expression” in a binding to make it where the Web Browser component in View can show the web page it is referring to?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [June 29, 2018, 9:29pm UTC](https://forum.inductiveautomation.com/t/decode-url-in-expression-for-view-component/18676/2 "2018-06-29T21:29:23Z")

</div>

There’s no direct expression function to use, but you can use the python built-in [urllib](https://docs.python.org/2/library/urllib.html#utility-functions) to unescape a sanitized URL. You _could_ put this into a runScript binding, either directly or by defining a simple helper function in a project/shared script.

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [June 29, 2018, 9:35pm UTC](https://forum.inductiveautomation.com/t/decode-url-in-expression-for-view-component/18676/3 "2018-06-29T21:35:14Z")

</div>

If you want to use only an expression, replace method could accomplish this:

```auto
replace(replace("http%3a%2f%2ftestsitportal.johndoe.net%2fEWIPortal%2fPortalPage%2f%2fCEWIViewer.aspx", "%3a", ":"), "%2f", "/")
# output: http://testsitportal.johndoe.net/EWIPortal/PortalPage//CEWIViewer.aspx

```

Replace the first string in it with a reference to the tag.

The weakness of this method is you have to hard-code in the appropriate replacements for any escaping that may be required.

---

<div class="post-metadata">

**Author:** ![jimjohnson](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@jimjohnson](https://forum.inductiveautomation.com/u/jimjohnson)\
**Post date:** [July 2, 2018, 5:25pm UTC](https://forum.inductiveautomation.com/t/decode-url-in-expression-for-view-component/18676/4 "2018-07-02T17:25:29Z")

</div>

The replace is working for the moment, but I keep having to add new ones.

On the script, would it stay updated so that as the link changes the screen keeps changing? And where would this go?

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [July 2, 2018, 5:36pm UTC](https://forum.inductiveautomation.com/t/decode-url-in-expression-for-view-component/18676/5 "2018-07-02T17:36:14Z")

</div>

Assuming you have a project script `project.url` with the following function defined:

```auto
def unescape(url):
    import urllib
    return urllib.unquote(url)

```

You would then construct a binding on your web browser component’s URL property as follows:  
`runScript('project.url.unescape', 0, {source/of/escaped/url})`

Every time the source property changes (wherever you’re getting these sanitized URLs from), it will fire the binding, which will run the project script and return the human-readable URL to the web browser component.
