javascript - Can an IndexedDB key of type "String" be a url path? -


i want use urls keys storing data in indexeddb. think valid key (from reading this: http://www.w3.org/tr/indexeddb/#key-construct ) not 100% certain. following valid keys?

//examples of storing keys objectstore.put( data, "http://example.com/some-url" ); objectstore.put( data, "http://example.com/some-url#s?e=t%20something&%20=%@" ); objectstore.put( data, "/some-url-relative-url/audio.mp3" ); objectstore.put( data, "/images/test.jpg" ); 

are there restrictions on characters can in key if it's string?

all strings can keys, unless hit memory limit or browser bugs.

this includes things like:

"" // empty string "abc\u0000def" // embedded null "\ud834\udd1e" // utf-16 surrogate pair "\uffff" // non-character "\ud800" // lone utf-16 surrogate 

so yes, stringified urls valid keys. of course, compared strings (sequences of 16-bit code units) may want/need perform url normalization first, depending on use case.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -