Hi All,I need help in encoding decoding of URL in JAVASCRIPT !Current URL : https://www.google.com/search?q=Nike×tamp=123123124 I used the function : encodeURIComponent(Data); but it is giving me link in form of http://www.google.com%2Fsearch%3Fq%3DNike%%26timestamp%3D20250317064706046User are able to see query parameters (Timestamp)
Expectation : www.google.com/asdfhjwenHJNJFnreujJNJ2323nmdfDNJn Url that should not be obvious !
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?
Hi @Omkar Ghodke, Is 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 :
Hi Balaji,Thankyou for your help !I dont want to encode the link totally, i just want to encode query parameters.
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
Hi Omkar,
have a look at below link,
https://www.outsystems.com/forums/discussion/42759/encode-the-url-parameter-values/
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.