Commit e0e855b5 authored by Clement Ho's avatar Clement Ho

Fix code review suggestions

parent c0287e69
......@@ -3,6 +3,10 @@
/* global droplab */
require('../window')(function(w){
function droplabAjaxException(message) {
this.message = message;
}
w.droplabAjax = {
_loadUrlData: function _loadUrlData(url) {
return new Promise(function(resolve, reject) {
......@@ -56,11 +60,7 @@ require('../window')(function(w){
}
hook.list[config.method].call(hook.list, d);
}).catch(function(e) {
if(e.message) {
console.error(e.message, e.stack); // eslint-disable-line no-console
} else {
console.error(e); // eslint-disable-line no-console
}
throw new droplabAjaxException(e.message || e);
});
},
......
......@@ -169,6 +169,8 @@
w.gl.utils.getParameterByName = (name) => {
const url = window.location.href;
name = name.replace(/[[\]]/g, '\\$&');
// Finds the value associated to the name
// Example, state=open where state is the name and open is the value
const regex = new RegExp(`[?&]${name}(=([^&#]*)|&|#|$)`);
const results = regex.exec(url);
if (!results) return null;
......
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