Closed jarrodek closed 8 years ago
Regex defined in history.js in line 416 do not parse chrome-extension:// protocol properly.
chrome-extension://
Chrome apps don't have history API and for some libraries to work the app need to include a polyfil.
Function parseURL() returns: _href - without undefined values protocol - is chrome-extension:// host - is not undefined _hostname - is not undefined
parseURL()
_href
undefined
protocol
host
_hostname
The result variable - after parsing the URL - have following values:
result
[ "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" }
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]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/
\w+
re
[a-zA-Z\-]+
/(?:([a-zA-Z\-]+\:))?(?:\/\/(?:[^@]*@)?([^\/:\?#]+)(?::([0-9]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/
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
- withoutundefined
valuesprotocol
- ischrome-extension://
host
- is not undefined_hostname
- is not undefinedActual outcome
The
result
variable - after parsing the URL - have following values:So in case of my application result of calling this function is:
Suggested solution
Replace first
\w+
in there
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]+))?)?([^\?#]*)(?:(\?[^#]+)|\?)?(?:(#.*))?/