Regex parsing the URL is not handing Chrome Apps
jarrodek opened this issue · 0 comments
Regex defined in history.js in line 416 do not parse chrome-extension://
protocol properly.
Chrome apps don't have history API and for some libraries to work the app need to include a polyfil.
Expected outcome
Function parseURL()
returns:
_href
- without undefined
values
protocol
- is chrome-extension://
host
- is not undefined
_hostname
- is not undefined
Actual outcome
The result
variable - after parsing the URL - have following values:
[
"chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo/!dataimport",
null,
null,
null,
"chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo/!dataimport",
null,
null
]
So in case of my application result of calling this function is:
{
"_href": "undefined//undefinedchrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo/!dataimport",
"_host": "undefined",
"_port": "",
"_pathname": "chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo/!dataimport",
"_search": "",
"_hash": "",
"_relative": "chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo/!dataimport",
"_nohash": "chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo/!dataimport",
"_special": "chrome-extension://hgmloofddffdnphfgcellkdfbfbjeloo/!dataimport"
}
Suggested solution
Replace first \w+
in the re
regex in referenced line to characters range for all letters and dash: [a-zA-Z\-]+
. So the final regex would be:
/(?:([a-zA-Z\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/