当前位置:网站首页>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 .
边栏推荐
- 图解八股,真的太顶了
- MySQL优化:从十几秒优化到三百毫秒
- Introduction to programming ape (11) -- structure
- NFS mount
- 【Hot100】11. Container with the most water
- How to convert XML to JSON
- Ls1028 manual
- Initial love with mqtt
- Install the components corresponding to setup
- Deep learning --- the weight of the three good students' scores (3)
猜你喜欢

Mysql5.7 compressed version installation tutorial

程序猿入门攻略(十一)——结构体

ROS system problem: rosdep init

MySQL Optimization: from more than ten seconds to 300 milliseconds

【我的OpenGL学习进阶之旅】关于OpenGL的着色器的向量和矩阵分类的访问方式: xyzw/rgba/stpq以及数组下标

GO安装以及配置(1)

【每日一题】535. TinyURL 的加密与解密

Introduction to programming ape (11) -- structure

1.9 - Classification of memory

SOC_AHB_SD_IF
随机推荐
memcpy内存重叠的解决
Solr search
基础刷题(一)
0 basic job transfer software test, how to achieve a monthly salary of 9.5k+
[datawhale team learning] task02: mathematical operation, string and text, list
6、 Shopping ⻋ and orders
How does the CPU recognize the code?
Pay attention to this live broadcast and learn about the path to achieve the dual carbon goal of the energy industry
【Hot100】15. Sum of three numbers
What if I forget my account number after opening an account? Is it safe to open an account online?
【Mask-RCNN】基于Mask-RCNN的目标检测和识别
C # - C # process and convert pixeldata of CT images with fo DICOM
SOC_ SD_ CLK
File transfer protocol, FTP file sharing server
Redis cache
RT thread Kernel Implementation (V): timer
Install the components corresponding to setup
【json-tutorial】第一章学习笔记
【转】存储器结构、cache、DMA架构分析
Unity中实现溶解(Dissolve)特效及其原理解析