Unverified Commit 99903f4a authored by Robert Knight's avatar Robert Knight Committed by GitHub

Merge pull request #1559 from hypothesis/use-fragment-to-pass-config

Use fragment instead of query to pass config to sidebar app
parents f0fcbdfa e074165f
...@@ -27,10 +27,8 @@ module.exports = class Host extends Guest ...@@ -27,10 +27,8 @@ module.exports = class Host extends Guest
configParam = 'config=' + encodeURIComponent( configParam = 'config=' + encodeURIComponent(
JSON.stringify(Object.assign({}, config, {sidebarAppUrl: undefined, pluginClasses: undefined })) JSON.stringify(Object.assign({}, config, {sidebarAppUrl: undefined, pluginClasses: undefined }))
) )
if config.sidebarAppUrl and '?' in config.sidebarAppUrl
sidebarAppSrc = config.sidebarAppUrl + '&' + configParam sidebarAppSrc = config.sidebarAppUrl + '#' + configParam
else
sidebarAppSrc = config.sidebarAppUrl + '?' + configParam
# Create the iframe # Create the iframe
app = $('<iframe></iframe>') app = $('<iframe></iframe>')
......
...@@ -78,7 +78,7 @@ describe 'Host', -> ...@@ -78,7 +78,7 @@ describe 'Host', ->
appURL = new URL('/base/annotator/test/empty.html', window.location.href) appURL = new URL('/base/annotator/test/empty.html', window.location.href)
host = createHost({annotations: '1234'}) host = createHost({annotations: '1234'})
configStr = encodeURIComponent(JSON.stringify({annotations: '1234'})) configStr = encodeURIComponent(JSON.stringify({annotations: '1234'}))
assert.equal(host.frame[0].children[0].src, appURL + '?config=' + configStr) assert.equal(host.frame[0].children[0].src, appURL + '#config=' + configStr)
it 'adds drop shadow if the clean theme is enabled', -> it 'adds drop shadow if the clean theme is enabled', ->
host = createHost({theme: 'clean'}) host = createHost({theme: 'clean'})
......
...@@ -7,7 +7,8 @@ const queryString = require('query-string'); ...@@ -7,7 +7,8 @@ const queryString = require('query-string');
* client. * client.
*/ */
function hostPageConfig(window) { function hostPageConfig(window) {
const configJSON = queryString.parse(window.location.search).config; const configStr = window.location.hash.slice(1);
const configJSON = queryString.parse(configStr).config;
const config = JSON.parse(configJSON || '{}'); const config = JSON.parse(configJSON || '{}');
// Known configuration parameters which we will import from the host page. // Known configuration parameters which we will import from the host page.
......
...@@ -5,7 +5,7 @@ const hostPageConfig = require('../host-config'); ...@@ -5,7 +5,7 @@ const hostPageConfig = require('../host-config');
function fakeWindow(config) { function fakeWindow(config) {
return { return {
location: { location: {
search: '?config=' + JSON.stringify(config), hash: '#config=' + JSON.stringify(config),
}, },
}; };
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment