我想使用参数«returnUrl»的倍数来检索url中的一些参数。
示例:
HTTPS://force.com?positionId=a0w0X000007HjBuQAK&lang=fr&mediaChannel=a0o0X00000EGQ5TQAX&returnUrl=https%253A%2F%2force.com%2Fcxsrec__cxsSearchDetail%3Fid%3Da0w0X000007HjBuQAK%26lang%3Dfr%26mediaChannel%3Da0o0X00000EGQ5TQAX%26returnUrl%3Dhttps%253A%2F%2force.com%2Fcxsrec__cxsSearch%253Flang%253Dfr%2526mediaChannel%253Da0o0X00000EGQ5TQA%2526 site%253DFrance%2526hcFilter%253Da0Z0X00000XiFF3UAN%252Ca0Z0X00000XiUqTUAV%2526orderBy%253DPosition_name__c%2526orderDir%253Dasc%2526mediaChannel%253Da0o0X00000EGQ5TQAX%26lang%3Dfr%26mediaChannel%3Da0o0X00000EGQ5TQAX’
?... returnUrl %3Dhttps%253A%2F%2force.com%2Fcxsrec__cxsSearch%253Flang%253Dfr%2526mediaChannel%253Da0o0X00000EGQ5TQA%2526 site site %253DFrance%2526hcFilter。 ..
我想获取参数 site 的值。
我尝试使用 decodeURI 函数,然后使用 searchParams.get(“ site”),但是 decodeURI 不能在< strong> returnUrl 。
还有其他功能可以做到这一点吗?
答案 0 :(得分:1)
您需要Firefox Bugzilla ticket 1525706。
我已删除URL中site
之前的空格:
const url1 = new URL('https://force.com?positionId=a0w0X000007HjBuQAK&lang=fr&mediaChannel=a0o0X00000EGQ5TQAX&returnUrl=https%253A%2F%2force.com%2Fcxsrec__cxsSearchDetail%3Fid%3Da0w0X000007HjBuQAK%26lang%3Dfr%26mediaChannel%3Da0o0X00000EGQ5TQAX%26returnUrl%3Dhttps%253A%2F%2force.com%2Fcxsrec__cxsSearch%253Flang%253Dfr%2526mediaChannel%253Da0o0X00000EGQ5TQA%2526site%253DFrance%2526hcFilter%253Da0Z0X00000XiFF3UAN%252Ca0Z0X00000XiUqTUAV%2526orderBy%253DPosition_name__c%2526orderDir%253Dasc%2526mediaChannel%253Da0o0X00000EGQ5TQAX%26lang%3Dfr%26mediaChannel%3Da0o0X00000EGQ5TQAX');
const params1 = new URLSearchParams(url1.search);
const returnUrl = params1.get('returnUrl');
const url2 = new URL(decodeURIComponent(returnUrl));
const params2 = new URLSearchParams(url2.search);
const site = params2.get('site');
console.log(site);
中查看一些详细信息