question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

null is not an object error when app is served from a URL scheme other than http or https

See original GitHub issue

Issue 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:closed
  • Created 9 months ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
karlvrcommented, Dec 15, 2022

@guillaume-chervet not at all, I’m super impressed and thankful for your quick responses and actions. A+. This issue is resolved.

1reaction
karlvrcommented, Dec 14, 2022

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix "Expected URL scheme 'http' or 'https' but no colon ...
It is an app, where I use spinner so a user can choose, depending on his choice, different data will be loaded. I...
Read more >
Defining a custom URL scheme for your app - Apple Developer
Register your URL scheme​​ URL scheme registration specifies which URLs to redirect to your app. Register your scheme in Xcode from the Info...
Read more >
Deep Linking in React Native with Universal Links and URL ...
Universal Links use a website URL scheme to deep link an app​​ By linking a domain name (that the developer or app company...
Read more >
Cross-Origin Resource Sharing (CORS) - MDN Web Docs
Cross-Origin Resource Sharing (CORS) is an HTTP-header based ... no domain other than https://foo.example can access the resource in a ...
Read more >
Understanding deep linking in Flutter with Uni Links
Deep linking with Flutter provides you with a web browser link that points to a specific part of an app that is already...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found