如果查询中包含 +(加号)符号,firebase Rest api equalto 搜索将失败

标签 firebase

我正在通过 Firebase Rest API 进行查询,尝试查找特定记录。索引全部设置好。

基本上,如果我执行如下查询,它将找不到任何记录(记录确实存在):

https://<firbeaseapp>.firebaseio.com/users.json?auth=<authcode>&orderBy="email"&equalTo="<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3d484e584f1649584e490c7d53524a55584f58135e5250" rel="noreferrer noopener nofollow">[email protected]</a>"

上述调用仅返回一个空记录集。

如果我搜索没有+符号的记录,一切正常。我需要对 + 符号或其他符号进行编码吗?

预先感谢您的帮助。

最佳答案

这是一个 URL 编码问题。 URL 中的 + 代表空格,而不是加号。您需要对参数中使用的所有值进行 URL 编码。假设 JavaScript:

var emailEncoded = encodeURIComponent('<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a7d2d4c2d58cd3c2d4d396e7c9c8d0cfc2d5c289c4c8ca" rel="noreferrer noopener nofollow">[email protected]</a>');
var url = 'https://<firbeaseapp>.firebaseio.com/users.json?auth=<authcode>&orderBy="email"&equalTo="' + emailEncoded + '"'

关于如果查询中包含 +(加号)符号,firebase Rest api equalto 搜索将失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32380460/

相关文章:

ios - 在 Firebase 实时数据库中存储数据

ios - Firebase崩溃错误:symbolFileMappings:upsert:请求包含无效参数

node.js - 使用 auth.user().onCreate 时无法读取未定义的属性 'uid'

java - Firebase 存储中的 'getBytes()' 和 'getStream()' 方法有什么区别?

javascript - 更新 TodoList 上的项目 Angularfire

swift - 如果没有互联网,swift 中的 Firebase Functions 不会返回任何内容

java - 在没有 Firebase 控制台的情况下向所有设备发送推送通知

与 Firebase 托管相比,Firebase 存储非常慢

javascript - Firebase实时数据库 - 迭代数组时获取数据

java - Glide 库加载 GIF 很慢