mirror of https://github.com/gorhill/uBlock.git
minor code review: use URL() to lookup query parameters
This commit is contained in:
parent
8b5a7aa398
commit
8b1c39507e
|
@ -1,7 +1,7 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
uBlock Origin - a browser extension to block requests.
|
uBlock Origin - a browser extension to block requests.
|
||||||
Copyright (C) 2014-2018 Raymond Hill
|
Copyright (C) 2014-present Raymond Hill
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
Home: https://github.com/gorhill/uBlock
|
Home: https://github.com/gorhill/uBlock
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* global CodeMirror */
|
/* global CodeMirror, uBlockDashboard */
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
@ -27,22 +27,22 @@
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
var q = window.location.search;
|
let params = new URL(document.location).searchParams;
|
||||||
var matches = q.match(/^\?url=([^&]+)/);
|
let assetKey = params.get('url');
|
||||||
if ( !matches || matches.length !== 2 ) { return; }
|
if ( assetKey === null ) { return; }
|
||||||
|
|
||||||
vAPI.messaging.send(
|
vAPI.messaging.send(
|
||||||
'default',
|
'default',
|
||||||
{
|
{
|
||||||
what : 'getAssetContent',
|
what : 'getAssetContent',
|
||||||
url: decodeURIComponent(matches[1])
|
url: assetKey
|
||||||
},
|
},
|
||||||
function(details) {
|
details => {
|
||||||
cmEditor.setValue(details && details.content || '');
|
cmEditor.setValue(details && details.content || '');
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
var cmEditor = new CodeMirror(
|
let cmEditor = new CodeMirror(
|
||||||
document.getElementById('content'),
|
document.getElementById('content'),
|
||||||
{
|
{
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
|
|
Loading…
Reference in New Issue