null is not an object error when app is served from a URL scheme other than http or https
See original GitHub issueIssue and Steps to Reproduce
When running the app using a URL scheme other than https?://
the regex in route-utils.ts
’s getLocation
fails with a “null is not an object” error when attempting to authenticate.
This is reproduced when using [Capacitor][https://capacitorjs.com] on iOS with a production build—the app is served from capacitor://
rather than http://
.
Versions
6.10.21
Possible resolution
The regex in route-utils.ts
’s getLocation
function could have its match for the scheme changed like so:
/^([a-z][\w-]+\:)\/\/(([^:\/?#]*)(?:\:([0-9]+))?)([\/]{0,1}[^?#]*)(\?[^#]*|)(#.*|)$/,
This correctly matches any URL scheme. It might also be worthwhile considering a more general regex e.g. from https://gist.github.com/gruber/249502
Also it would be useful to check for a null
result from href.match
to report a better error than “null is not an object … t[6]” as it’s quite hard to track down!
Issue Analytics
- State:
- Created 9 months ago
- Comments:9 (6 by maintainers)
Top GitHub Comments
@guillaume-chervet not at all, I’m super impressed and thankful for your quick responses and actions. A+. This issue is resolved.
@guillaume-chervet thank you very much; do you mean a sample URL that our app runs as? That would be
capacitor://localhost/index.html
. Or let me know if there’s anything else you need.