38
Views
6
Comments
Encoding Decoding URL in JS
Application Type
Reactive
Service Studio Version
11.55.12 (Build 64016)

Hi All,
I need help in encoding decoding of URL in JAVASCRIPT !
Current URL : https://www.google.com/search?q=Nike&timestamp=123123124 
I used the function : encodeURIComponent(Data); but it is giving me link in form of 
http://www.google.com%2Fsearch%3Fq%3DNike%%26timestamp%3D20250317064706046
User are able to see query parameters (Timestamp)

Expectation : www.google.com/asdfhjwenHJNJFnreujJNJ2323nmdfDNJn 
Url that should not be obvious !


2026-01-28 16-57-48
Mihai Melencu
Champion

Hi @Omkar Ghodke ,

encodeURI() only makes your URL safe by escaping special characters, it doesn't hide your parameters. 

If you are trying this feature for external URLs I recommend using a URL shortener. When someone visits that short URL, your server looks up the corresponding parameters and redirects them to the full URL. Here are a few components:

Also you can check this article:  Outsystems URL Shortener


If you are looking for this feature in your own application you can use GUIDs instead of regular IDs, you can follow this guide: What is GUID and how to use it in Outsytems?

UserImage.jpg
Chiranjeevi Balaji

Hi @Omkar GhodkeIs this the output you were expecting?

function encodeURL(url) {            

    return btoa(url);        

}        

function decodeURL(encodedUrl) {            

    return atob(encodedUrl);       

}        

const url = "https://www.google.com/search?q=Nike×tamp=123123124";        

const encodedUrl = encodeURL(url);        

console.log("Encoded URL:", `www.google.com/${encodedUrl}`);        

const decodedUrl = decodeURL(encodedUrl);        

console.log("Decoded URL:", decodedUrl);


Output :


UserImage.jpg
Omkar Ghodke

Hi Balaji,
Thankyou for your help !
I dont want to encode the link totally, i just want to encode query parameters.

2022-12-30 07-28-09
Navneet Garg

you can try following article to create a url shortener 

https://medium.com/@philip.paolo/outsystems-url-shortener-35cba57c767a

or use api to generate

https://publicapi.dev/free-url-shortener-api



2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Omkar,

An encoder is not an encrypter! What you want is simply not possible. The part after the domain name must refer to an existing destination/page on the web server. That's not OutSystems, that's the web server needing to know what page it should serve.

There are various ways to obscure parameters to a page, like using a GUID and then storing in the database the GUID + the relating parameters. But use this only if you really must, because it will give you a lot of overhead, programmatically.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.