Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Uncaught JS exception when malformed URL is supplied #517

Closed
fluorumlabs opened this issue Nov 23, 2020 · 1 comment · Fixed by #565
Closed

Uncaught JS exception when malformed URL is supplied #517

fluorumlabs opened this issue Nov 23, 2020 · 1 comment · Fixed by #565
Assignees
Labels

Comments

@fluorumlabs
Copy link

Steps to reproduce:

  1. Navigate to https://cookbook.vaadin.com// (two trailing slashes)

Observe:

Uncaught TypeError: Failed to construct 'URL': Invalid URL
    at Function.__createUrl (vaadin-bundle-5a8c8610a0f26788a61d.cache.js:2399)
    at re.get __effectiveBaseUrl [as __effectiveBaseUrl] (vaadin-bundle-5a8c8610a0f26788a61d.cache.js:2399)
    at re.__normalizePathname (vaadin-bundle-5a8c8610a0f26788a61d.cache.js:2399)
    at re.__onNavigationEvent (vaadin-bundle-5a8c8610a0f26788a61d.cache.js:2399)
    at re.setRoutes (vaadin-bundle-5a8c8610a0f26788a61d.cache.js:2399)
    at Module.<anonymous> (vaadin-bundle-5a8c8610a0f26788a61d.cache.js:2847)
    at i (vaadin-bundle-5a8c8610a0f26788a61d.cache.js:1)
    at vaadin-bundle-5a8c8610a0f26788a61d.cache.js:1
    at vaadin-bundle-5a8c8610a0f26788a61d.cache.js:1
@Haprog Haprog changed the title Uncought JS exception when malformed URL is supplied Uncaught JS exception when malformed URL is supplied Dec 8, 2020
@haijian-vaadin
Copy link
Contributor

haijian-vaadin commented Dec 8, 2020

Fix the exception so that the process could continue

@platosha platosha self-assigned this Jan 29, 2021
platosha added a commit that referenced this issue Feb 12, 2021
Fixes #517

When not set explicitly, the router constructor discovers `baseUrl`
using the `<base href>` value and initial document URL. However, only
the pathname from the discovered base URL was taken for the default
value of the `baseUrl` property. In case of initial pathname starting with
double slash `//`, such a value was then throwing `Invalid URL` error when
used as the URL constructor’s first argument.

This changes the default value discovery of `baseUrl`, so that it uses
an actual URL instead of only pathname to avoid throwing errors.
platosha added a commit that referenced this issue Feb 15, 2021
Fixes #517

When not set explicitly, the router constructor discovers `baseUrl`
using the `<base href>` value and initial document URL. However, only
the pathname from the discovered base URL was taken for the default
value of the `baseUrl` property. In case of initial pathname starting with
double slash `//`, such a value was then throwing `Invalid URL` error when
used as the URL constructor’s first argument.

This changes the default value discovery of `baseUrl`, so that it uses
an actual URL instead of only pathname to avoid throwing errors.
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants