我有一个以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"
并返回整个数据集:
{
"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"
它返回一个空集:
{}
我想也许我需要对查询参数进行urlencode,所以我尝试了:
https://fb-query-tester.firebaseio.com/urls.json?orderBy="$key"&startAt="http%253A"
但它仍然没有返回。我不知道此时该怎么做。请帮忙!
答案 0 :(得分:2)
看起来您可以使用双倍百分比来编码百分比。但是您必须对它们进行网址编码,因此您可以使用%%
而不是%
来代替每个%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"