Skip to content

Commit

Permalink
docs: resolved various issues with the demo app (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Woodward committed May 14, 2019
1 parent 70df8f0 commit 61bc6d1
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require('url-polyfill');
require('@babel/polyfill');
require('@webcomponents/webcomponentsjs/custom-elements-es5-adapter.js');
require('@webcomponents/webcomponentsjs');
Expand Down Expand Up @@ -47,25 +48,26 @@ const configs = {
}
};

const url = new URL(location.href);

const queryParams = Object.assign({
'provider': localStorage.getItem('salte.demo.provider') || 'auth0',
'login-type': 'redirect',
'response-type': localStorage.getItem('salte.demo.response-type') || 'id_token',
'redirect-url': 'single',
'storage-type': localStorage.getItem('salte.demo.storage-type') || 'session',
'secured': localStorage.getItem('salte.demo.secured') || 'not-secured'
}, location.search.replace(/^\?/, '').split('&').reduce((r, a) => {
const match = a.match(/([^=]+)(?:=([^&]+))?/);
const key = match && match[1] || null;
const value = match && match[2] || null;
}, Array.from(url.searchParams.keys()).reduce((output, key) => {
const value = url.searchParams.get(key);
if (value === 'false') {
r[key] = false;
output[key] = false;
} else if (value === 'true') {
r[key] = true;
output[key] = true;
} else {
r[key] = value;
output[key] = value;
}
return r;

return output;
}, {}));

elements.provider.value = queryParams.provider;
Expand Down

0 comments on commit 61bc6d1

Please sign in to comment.