GetWeixinCode icon indicating copy to clipboard operation
GetWeixinCode copied to clipboard

单页应用spa, 路由使用hash模式, 会导致重定向的url异常

Open ethanyou725 opened this issue 7 years ago • 5 comments
trafficstars

路由使用hash模式时候, 也就是说redirect_uri 中包含#, 比如redirect_uri为 http://test.com/#/product/1, 最终重定向的地址为 http://test.com/?code=code&state=state#/product/1 正确是应该是 http://test.com/#/product/1?code=code&state=state 随着前端单页的流行, 这样的url会导致一些问题

ethanyou725 avatar Apr 29 '18 16:04 ethanyou725

@Youzhigang 抱歉回复晚了。最近项目比较忙,上次看到忘记回复了。目前的处理没考虑到单页应用的URL结构,回头有空我优化下。

HADB avatar Jun 20 '18 09:06 HADB

也欢迎提交PR

HADB avatar Jun 20 '18 09:06 HADB

其实这个问题也不是太大的问题,
url为: http://test.com/?code=code&state=state#/product/1时候 window.location.search = ?code=code&state=state window.location.hash = #/product/1 url为http://test.com/#/product/1?code=code&state=state 时 window.location.search = '' window.location.hash = #/product/1?code=code&state=state

我们项目里先取到code后, 通过 window.history.replaceState(null,null,window.location.href.replace(window.location.search, '') ) 来过滤url

ethanyou725 avatar Jun 25 '18 05:06 ethanyou725

参数给我弄丢了。。。。。

xuehf avatar Nov 15 '18 02:11 xuehf

image 这么长的redirecturl最后剩下一个参数了。

xuehf avatar Nov 15 '18 03:11 xuehf