This commit is contained in:
Cade Scroggins
2019-03-07 23:48:07 -08:00
parent 478149c28c
commit 9929880f6b
+5 -8
View File
@@ -1043,17 +1043,14 @@
this._pathDelimiter = options.pathDelimiter; this._pathDelimiter = options.pathDelimiter;
this._protocolRegex = /^[a-zA-Z]+:\/\//i; this._protocolRegex = /^[a-zA-Z]+:\/\//i;
this._urlRegex = /^((https?:\/\/)?[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?)$/i; this._urlRegex = /^((https?:\/\/)?[\w-]+(\.[\w-]+)+\.?(:\d+)?(\/\S*)?)$/i;
this._cachedQuery = '';
this._cachedRes = null;
this.parse = this.parse.bind(this); this.parse = this.parse.bind(this);
this._lastQuery = "";
this._lastParse;
} }
parse(query) { parse(query) {
if (this._lastQuery === query) { if (this._cachedQuery === query) return this._cachedRes;
return this._lastParse; this._cachedQuery = query;
}
this._lastQuery = query;
const res = { query: query, split: null }; const res = { query: query, split: null };
if (this._urlRegex.test(query)) { if (this._urlRegex.test(query)) {
@@ -1097,7 +1094,7 @@
} }
res.color = QueryParser._getColorFromUrl(this._commands, res.redirect); res.color = QueryParser._getColorFromUrl(this._commands, res.redirect);
this._lastParse = res; this._cachedRes = res;
return res; return res;
} }