Encode rpc=<url> param (#3751)

This commit is contained in:
Jaco Greeff 2020-09-23 19:16:57 +02:00 committed by GitHub
parent be0613ad1e
commit b0379d4cd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 2 deletions

View File

@ -194,7 +194,7 @@ function Endpoints ({ className = '', offset, onClose }: Props): React.ReactElem
(): void => {
uiSettings.set({ ...(uiSettings.get()), apiUrl });
window.location.assign(`${window.location.origin}${window.location.pathname}?rpc=${apiUrl}${window.location.hash}`);
window.location.assign(`${window.location.origin}${window.location.pathname}?rpc=${encodeURIComponent(apiUrl)}${window.location.hash}`);
// window.location.reload();
onClose();

View File

@ -18,7 +18,8 @@ function getApiUrl (): string {
if (urlOptions.rpc) {
assert(!Array.isArray(urlOptions.rpc), 'Invalid WS endpoint specified');
const url = urlOptions.rpc.split('#')[0]; // https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:9944#/explorer;
// https://polkadot.js.org/apps/?rpc=ws://127.0.0.1:9944#/explorer;
const url = decodeURIComponent(urlOptions.rpc.split('#')[0]);
assert(url.startsWith('ws://') || url.startsWith('wss://'), 'Non-prefixed ws/wss url');