Skip to content

window.location.hash

Jonathan Montane edited this page Nov 8, 2016 · 2 revisions

Since hash are not sent with the request, we can use it to store large amount of data (up to a few million characters), which allows us to create a client side api where one can pass a text file as well as a few other information points (name, format, url, origin)

Parameters

  • content [required]: the content of the imported file, base64 encoded
  • name: the name of the imported file
  • format: the format of the imported file
  • url: the url of the imported file
  • origin: name of the app or service that provided the file (eg: Paw)

Structure

The hash parser expects the hash to respect the following pattern: ^/#\?(?params:.*)/ The params object should respect the URL RFC for query parameters (ie key-value, & separator, uri-encoded)

For readability purpose, content should always be the last parameter appended to the query-string

Examples of hash:

Hash with high amount of information

https://console.rest/#?name=swagger.json&format=swagger&url=http://petstore.swagger.io/v2/swagger.json&origin=paw&content=eyJzd2FnZ2VyIjoiMi4wIiwiaW5mbyI6eyJkZXNjcmlwd...QawWZ%3D

Hash with low amount of information

https://console.rest/#?content=eyJzd2FnZ2VyIjoiMi4wIiwiaW5mbyI6eyJkZXNjcmlwd...QawWZ%3D