带有多个问号的角柄查询参数

问题描述

我正在尝试处理由Firebase自动生成的电子邮件确认链接,该链接进入Web平台上的Ionic / Angular应用程序。 我尝试使用Deeplink cordova插件(文档称它支持Web),但返回“ cordova_not_available”错误。 我尝试使用电容器App插件,但它在浏览器上返回认的空字符串。 我尝试调用location.toString(),但是该链接查询参数值中包含多个问号,并且从第二个问号开始的所有内容都被删除。 Firebase生成链接如下:

https://example.com?link=https://example.com?apiKey%3D{myApiKey}%26mode%3DverifyEmail%26oobCode%3D{theCodeIneed}%26continueUrl%3Dhttps://example.com/email-confirmed%26lang%3Den&apn=com.example.myAppName&amv&ibi=com.example.myAppName&ifl=https://example.com?apiKey%3D{myApiKey}%26mode%3DverifyEmail%26oobCode%3D{theCodeIneed}%26continueUrl%3Dhttps://example.com/email-confirmed/%26lang%3Den

但是我从location.toString()(到目前为止最好的)中得到的只是:

https://example.com?link=https://example.com

所以我无法获取 oobCode 参数,这是我需要确认用户拥有该电子邮件地址的条件

有没有办法获得完整链接

解决方法

我终于发现,通过在sendPasswordResetEmail或sendEmailVerification Firebase方法的actionCodeSettings参数中设置handleCodeInApp = false,Firebase自动生成的链接恰好只有一个问号(我不知道为什么),因此可以通过location.toString()对其进行管理以检索oobCode。