Skip to content

Improve URL handling to prevent constructor errors#4

Open
ylevch wants to merge 1 commit intomainfrom
bugfix/handle-invalid-url
Open

Improve URL handling to prevent constructor errors#4
ylevch wants to merge 1 commit intomainfrom
bugfix/handle-invalid-url

Conversation

@ylevch
Copy link
Owner

@ylevch ylevch commented Apr 14, 2023

Description:

  • This pull request addresses an issue encountered when constructing a URL object with an invalid URL in the background.js. The changes made ensure that the URL constructor is only called when the current URL matches the Google Books URL pattern, preventing the "TypeError: Failed to construct 'URL': Invalid URL at..." error.

Changes:

  • Moved the URL object creation and subsequent code inside a conditional block that checks if the current URL matches the Google Books pattern.
  • This ensures that the URL constructor is only called for valid Google Books URLs, preventing the error from occurring.

Testing:

  • Tested the extension with various Google Books URLs to ensure that the intended redirection still works as expected.
  • Tested with non-Google Books URLs (including hidden Chrome URLs, e.g., chrome://extensions) to verify that the error is no longer encountered.

@ylevch
Copy link
Owner Author

ylevch commented Apr 14, 2023

I think I'll have to increase version number in manifest.json to comply with Chrome Web Store update rules.

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.

1 participant