Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: properly handle data URIs #27

Merged
merged 6 commits into from
May 20, 2021
Merged

fix: properly handle data URIs #27

merged 6 commits into from
May 20, 2021

Conversation

gkatsev
Copy link
Member

@gkatsev gkatsev commented May 20, 2021

There are the following two cases:

  • a data URI is provided for the baseURL
    • in this case, ignore the data URI and resolve against window.location or a default location
  • a data URI is provided for the relativeURL
    • in this case, return the data URI as it should be treated as an absolute URL

Fixes videojs/video.js#7240

@@ -9,6 +9,11 @@ const resolveUrl = (baseUrl, relativeUrl) => {
return relativeUrl;
}

// if baseUrl is a data URI, ignore it and resolve everything relative to window.location
if ((/^data:/).test(baseUrl)) {
baseUrl = window.location && window.location.href;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we add an || '' to the end here so that baseUrl isn't undefined in node?

@gkatsev gkatsev merged commit 9b10245 into main May 20, 2021
@gkatsev gkatsev deleted the data-uris branch May 20, 2021 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to construct 'URL': Invalid URL on videojs 7.12.2
2 participants