readium / readium-shared-js

Repository for the shared JavaScript libraries that are used in the SDK-Launchers and other applications developed on top of the SDK
BSD 3-Clause "New" or "Revised" License
78 stars 102 forks source link

Extend `buildUrlQueryParameters` helper #427

Closed jccr closed 6 years ago

jccr commented 6 years ago

Partial rewrite of buildUrlQueryParameters helper to support the preservation of query strings in the initial URL as well as the hash fragment.

The overrides feature now also has a way to control the escaping of a supplied param value.

Example usage:

Helpers.buildUrlQueryParameters('http://example.com?preservedQuery1=test#helloWorld', {
  // characters will be escaped by helper
  epub: 'some/path/to/epub', 
  // no escaping applied by helper for the following
  goto: {
    value: encodeURI('epubcfi(/6/2!4/2/2[text_assert])'),
    verbatim: true
  } 
});

Output:

http://example.com/?epub=some%2Fpath%2Fto%2Fepub&goto=epubcfi(/6/2!4/2/2%5Btext_assert%5D)&preservedQuery1=test#helloWorld

jccr commented 6 years ago

Fixes #426