简体   繁体   English

无法在Firebase中具有特殊字符的键上使用startAt选项

[英]Can't use startAt option on keys with special characters in firebase

I have a firebase dataset with URLs as keys, such as in this example: 我有一个使用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
  }
}

Using the REST API, when I try to specify a startAt string that includes some kind of special character like %, it stops working. 使用REST API时,当我尝试指定包含某种特殊字符(如%)的startAt字符串时,它将停止工作。 For example, the following query works fine: 例如,以下查询可以正常工作:

https://fb-query-tester.firebaseio.com/urls.json?orderBy="$key"&startAt="http"

And returns the whole dataset: 并返回整个数据集:

{
    "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
}

But when I try: 但是当我尝试:

https://fb-query-tester.firebaseio.com/urls.json?orderBy="$key"&startAt="http%3A"

It returns an empty set: 它返回一个空集:

{}

I thought maybe I needed to urlencode the query parameter, so I tried: 我以为可能需要对查询参数进行urlencode,所以我尝试了:

https://fb-query-tester.firebaseio.com/urls.json?orderBy="$key"&startAt="http%253A"

But it still returned nothing. 但是它仍然什么也没有返回。 I'm not sure what to do at this point. 我目前不确定该怎么办。 Please help! 请帮忙!

It looks like you can use double-percents to encode a percent. 看起来您可以使用双百分数来编码百分数。 But you have to URL-encode them, so instead of using %% in place of each % , you would use %25%25 . 但是您必须对其进行URL编码,因此,您将使用%25%25而不是使用%%代替每个%

So for your example, you could start at the second entry using this 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从第二个条目开始: 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" : 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"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM