无法在 firebase 中具有特殊字符的键上使用 startAt 选项
Can't use startAt option on keys with special characters in firebase
我有一个以 URL 作为键的 firebase 数据集,例如在这个例子中:
{
"urls" : {
"http%3A%2F%2Flincoln%2Emetacannon%2Enet%2F2005%2F10%2Ffashion-of-gods%2Easpx" : true,
"http%3A%2F%2Flincoln%2Emetacannon%2Enet%2F2005%2F10%2Fgod-is-dead-again%%2Easpx" : true,
"http%3A%2F%2Flincoln%2Emetacannon%2Enet%2F2005%2F10%2Fzugos%2Easpx" : true,
"http%3A%2F%2Flincoln%ZZmetacannon%ZZnet%2F2005%2F11%2Fgods-creature%ZZaspx" : true
}
}
使用 REST API,当我尝试指定一个包含某种特殊字符(如 %)的 startAt 字符串时,它停止工作。例如,以下查询工作正常:
https://fb-query-tester.firebaseio.com/urls.json?orderBy="$key"&startAt="http"
和returns整个数据集:
{
"http%3A%2F%2Flincoln%2Emetacannon%2Enet%2F2005%2F10%2Ffashion-of-gods%2Easpx": true,
"http%3A%2F%2Flincoln%2Emetacannon%2Enet%2F2005%2F10%2Fgod-is-dead-again%%2Easpx": true,
"http%3A%2F%2Flincoln%2Emetacannon%2Enet%2F2005%2F10%2Fzugos%2Easpx": true,
"http%3A%2F%2Flincoln%ZZmetacannon%ZZnet%2F2005%2F11%2Fgods-creature%ZZaspx": true
}
但是当我尝试时:
https://fb-query-tester.firebaseio.com/urls.json?orderBy="$key"&startAt="http%3A"
它returns一个空集:
{}
我想也许我需要对查询参数进行 urlencode,所以我尝试了:
https://fb-query-tester.firebaseio.com/urls.json?orderBy="$key"&startAt="http%253A"
但它仍然没有返回任何内容。我不确定此时该做什么。请帮忙!
看来您可以使用双百分号来编码百分号。但是你必须对它们进行 URL 编码,所以不是使用 %%
代替每个 %
,而是使用 %25%25
.
因此,对于您的示例,您可以使用此 URL 从第二个条目开始:
https://fb-query-tester.firebaseio.com/urls.json?orderBy="$key"&startAt="http%25%253A%25%252F%25%252Flincoln%25%252Emetacannon%25%252Enet%25%252F2005%25%252F10%25%252Fgod-is-dead-again%25%25%25%252Easpx"
我有一个以 URL 作为键的 firebase 数据集,例如在这个例子中:
{
"urls" : {
"http%3A%2F%2Flincoln%2Emetacannon%2Enet%2F2005%2F10%2Ffashion-of-gods%2Easpx" : true,
"http%3A%2F%2Flincoln%2Emetacannon%2Enet%2F2005%2F10%2Fgod-is-dead-again%%2Easpx" : true,
"http%3A%2F%2Flincoln%2Emetacannon%2Enet%2F2005%2F10%2Fzugos%2Easpx" : true,
"http%3A%2F%2Flincoln%ZZmetacannon%ZZnet%2F2005%2F11%2Fgods-creature%ZZaspx" : true
}
}
使用 REST API,当我尝试指定一个包含某种特殊字符(如 %)的 startAt 字符串时,它停止工作。例如,以下查询工作正常:
https://fb-query-tester.firebaseio.com/urls.json?orderBy="$key"&startAt="http"
和returns整个数据集:
{
"http%3A%2F%2Flincoln%2Emetacannon%2Enet%2F2005%2F10%2Ffashion-of-gods%2Easpx": true,
"http%3A%2F%2Flincoln%2Emetacannon%2Enet%2F2005%2F10%2Fgod-is-dead-again%%2Easpx": true,
"http%3A%2F%2Flincoln%2Emetacannon%2Enet%2F2005%2F10%2Fzugos%2Easpx": true,
"http%3A%2F%2Flincoln%ZZmetacannon%ZZnet%2F2005%2F11%2Fgods-creature%ZZaspx": true
}
但是当我尝试时:
https://fb-query-tester.firebaseio.com/urls.json?orderBy="$key"&startAt="http%3A"
它returns一个空集:
{}
我想也许我需要对查询参数进行 urlencode,所以我尝试了:
https://fb-query-tester.firebaseio.com/urls.json?orderBy="$key"&startAt="http%253A"
但它仍然没有返回任何内容。我不确定此时该做什么。请帮忙!
看来您可以使用双百分号来编码百分号。但是你必须对它们进行 URL 编码,所以不是使用 %%
代替每个 %
,而是使用 %25%25
.
因此,对于您的示例,您可以使用此 URL 从第二个条目开始:
https://fb-query-tester.firebaseio.com/urls.json?orderBy="$key"&startAt="http%25%253A%25%252F%25%252Flincoln%25%252Emetacannon%25%252Enet%25%252F2005%25%252F10%25%252Fgod-is-dead-again%25%25%25%252Easpx"