当前位置:网站首页>Record common problems: spaces in encodeuricomponent decoding and the use of Schema in third-party apps to invoke apps
Record common problems: spaces in encodeuricomponent decoding and the use of Schema in third-party apps to invoke apps
2022-06-30 06:59:00 【Zmmm Jun】
window.location.hrefUsed when jumpingencodeURIComponentSome parameters are encoded , But in a third party app There are line breaks and spaces in the encoded parameters ( Some third-party applications or java Program )The code is as follows
const domain = this.app.isProd()?"https://xfkh.foundersc.com/":'https://kaihu-dev-cstest.fzzqxf.com/' window.location.href = domain + "api/result/resultDesc?token=" + encodeURIComponent(this.app.getToken());** Solution ** stay `encodeURIComponent(this.app.getToken())` Put another layer on the outside `encodeURIComponent` All codes are as follows :
const domain = this.app.isProd()?"https://xfkh.foundersc.com/":'https://kaihu-dev-cstest.fzzqxf.com/'
window.location.href = domain + "api/result/resultDesc?token=" + encodeURIComponent(encodeURIComponent(this.app.getToken()));
** Principle view **
1. Guess is in the jump process `token` The interior contains `+` Number , During message transmission `+` The sign will automatically become a space , So use it again `encodeURIComponent` Carry out secondary coding , take `+` Number is converted to `%20F` Such a hexadecimal encoding unicode character , In this way, the message will not appear when it is received at the back end ` Space `
2. But I'm curious , Why can there be... When transcoding for the first time `+` No. remaining , Obviously I used it the first time `encodeURIComponent` This step , Why do you still have `+` Number , And why + When the server gets the number, it becomes ` Space `, Two codes / Is the decoding method different `#todo`
3. Use `encodeURICompnent` Why , Because in url In order to prevent ` Some ambiguous characters are carried in the parameter , For example, the transmission of parameters ? Sign or parallel symbol & Even the equal sign ` Or to avoid being in `url The access process is not ascill Transcoding differences of encoded characters during the request process ` So in the transmission of special characters or non `asscill` When encoding characters, you need to use `encodeURIComponent` This method encodes the parameters , But it usually happens in `get` There are a lot of , because `get` The requested parameters are carried directly in `url` It says , While using `post` Request parameters can be in the form of ` message ` In the form of , We can avoid this problem
4. As for why the server or third-party applications put `+` Escape into ` Space `: The server is getting `url` Parameter will also be used `decode` In the process `+` The number will be decode become ` Space `??? Still a bit of a forced explanation
Third party browsers are not available schema evoke app as well as schema What the hell is that?
In the mobile terminal browser, click
schemaThe agreement evokes app,schemaIt's a similar one http Page Jump protocol ,andriodandiosAll support the protocol , However, supporting this protocol requires the browser to set certain rules , Some third-party browsers do not implement or restrict thisschemaJump abilityschemaThe protocol andhttpThe rules of the agreement are similar , Is a jump protocol between pages , Not just forappJump between also applies toh5JumpappSuch passage scheme The way to open local applications is not supported by all browsers , In particular, wechat browser does not support the use of scheme Open the app's , Unless wechat officially adds a white list .QQ The browser supports .
And some browsers will ask the user whether to open , Others open applications directly .
The general way is , Judge whether the current browser is wechat , If it's wechat , Then a mask layer pops up , Prompt the user to open using another browser .
There is also the wechat download of APP treasure in the wechat browser , Redirect the current page to the download page of the app , However, the conversion rate of this method is very low .
The good news is , stay IOS9.0 In the above systems , have access to universal links Open local application , however Android I won't support it .
Another alternative is , In wechat browser , Use iframe To open a package address (.apk At the end of the url) When downloading , Will pull up a selection box , Lets you choose which apps to open . However, this method is invalid for some domain names , Invalid for some special download files , If you can't download .rar The file of . And for users who have already installed the application , The user experience is not good either .
While using this technology , Considering its uncertainty , Alternatives should be made . Fully consider whether the user group of this page is mainly new users , And the distribution of browsers visited , So as to formulate corresponding guidance and alternative solutions that are more friendly to users .
边栏推荐
- Basic questions (I)
- [my advanced OpenGL learning journey] about the access methods of vector and matrix classification of OpenGL shaders: xyzw/rgba/stpq and array subscripts
- 编写并运行第一个Go语言程序
- 0基础转行软件测试,如何实现月薪9.5k+
- Four great happenings on earth
- No module named 'pyqt5 QtMultimedia‘
- 经纬恒润再次荣获PACCAR集团 10PPM 质量奖
- 六,购物⻋与订单
- SOC_ SD_ CLK
- Records of problems solved (continuously updated)
猜你喜欢

Steps for formulating class or file templates in idea

Introduction to programming ape (11) -- structure

CPU到底是怎么识别代码的?

Performance comparison of random network, scale-free network, small world network and NS small world matlab simulation

Initial love with mqtt

Basic questions (I)

第一行代码(第三版)学习笔记

app闪退

【Mask-RCNN】基于Mask-RCNN的目标检测和识别

InnoDB engine in MySQL
随机推荐
Basic questions (I)
[datawhale team learning] task02: mathematical operation, string and text, list
1.9 - Cache
RT thread Kernel Implementation (I): threads and scheduling
原理:WebMvcConfigurer 与 WebMvcConfigurationSupport避坑指南
memcpy内存重叠的解决
史上最全一句话木马
记录一次腾讯测试开发工程师自动化接口测试实践经验
Redis cache
1.2 (supplementary)
MySQL中的InnoDB引擎
leetcode:98. Validate binary search tree
第一行代码(第三版)学习笔记
No module named 'pyqt5 QtMultimedia‘
汇编语言学习一(有栈协程铺垫,32位寄存器和相关指令学习,未完待续06/29)
Four great happenings on earth
SOC_SD_CLK
[JSON tutorial] Chapter 1 learning notes
1.9 - Classification of memory
Relevant database questions.