Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

怎么处理 window.location.href? #3

Open
karosLi opened this issue Mar 12, 2020 · 4 comments
Open

怎么处理 window.location.href? #3

karosLi opened this issue Mar 12, 2020 · 4 comments

Comments

@karosLi
Copy link

karosLi commented Mar 12, 2020

本地启动web server,那 window.location.href 肯定会改变成 localhost,如果H5页面针对这个做了逻辑:比如,针对 window.location.href 来判断H5的api环境,或者是第三方统计 JS 基于 window.location.href 来做页面埋点和流量分析,这些都会是问题。

@al-liu
Copy link
Owner

al-liu commented Mar 12, 2020

这种情况不要做这种离线包方案了,就访问线上页面,对缓存多做一些优化。

@karosLi
Copy link
Author

karosLi commented Aug 3, 2020

嗯,基于现有的项目,都已经是离线包了,很难说再转到非离线包。

我这边还是基于 URLProtocol 做了请求拦截,body 是在 h5 发送前缓存起来的,然后在native侧去获取,最后在URLProtocol发送时补上 body。

@al-liu
Copy link
Owner

al-liu commented Aug 4, 2020

WKWebView 还用 URLProtocol 吗,使用私有 api 有被拒的风险怎么办?

@karosLi
Copy link
Author

karosLi commented Aug 5, 2020

目前没有被拒绝过,可以通过字符串拼接的形式使用私有api。

另外我也做了一个纯的 ajax hook 方案,是基于 jsbridge 去发送请求,当真有被拒的时候,可以切换到这套方式。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants