GetWeixinCode
GetWeixinCode copied to clipboard
单页应用spa, 路由使用hash模式, 会导致重定向的url异常
路由使用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会导致一些问题
@Youzhigang 抱歉回复晚了。最近项目比较忙,上次看到忘记回复了。目前的处理没考虑到单页应用的URL结构,回头有空我优化下。
也欢迎提交PR
其实这个问题也不是太大的问题,
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
参数给我弄丢了。。。。。
这么长的redirecturl最后剩下一个参数了。