简体   繁体   中英

How can i get the value from URL search params after %20?

I have implemented deeplinking functonality in our properly but i have a problem to get the value after %20 in URL My current URL:

https://halarewards.com/geturl.php?URL_SCHEME=HalaRewards://app/alloffers&DEEPLINK_SCHEME=https&DEEPLINK_HOST=halarewards.com&pagename=alloffers&categoryname=Beauty%20&%20Wellness "

In above URL we have get the value of categoryname via searchparams:

//get key value from URL var name = currentURL.searchParams.get('categoryname');

it will be return Only 'Beauty' instead of a 'Beauty & Wellness'.i will get whole categoryname value from above URL but in my current scenario it will be return only Beauty.tell me anyone how to get to get the value after %20 in ionic2 or javscript?

If you're creating the URL you would need to percent-encode the ampersand between "Beauty" and "Wellness". For example Beauty%20%26%20Wellness:

 const link = 'https://halarewards.com/geturl.php?URL_SCHEME=HalaRewards://app/alloffers&DEEPLINK_SCHEME=https&DEEPLINK_HOST=halarewards.com&pagename=alloffers&categoryname=Beauty%20%26%20Wellness' const url = new URL(link); alert(url.searchParams.get('categoryname')); // "Beauty & Wellness" 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM