fix: support country-specific Google domains#3
Open
yusiwen wants to merge 1 commit into
Open
Conversation
The extension was hardcoded to https://www.google.com/* in 5 places, preventing it from working on any country-specific Google domain. Chrome extension match patterns only allow single-label wildcards (*), so 4 patterns are needed to cover all Google TLD variants: - https://www.google.com/* (main domain) - https://www.google.*/* (single TLD: .de, .fr, .it, ...) - https://www.google.com.*/* (two-part TLD: .com.hk, .com.au, ...) - https://www.google.co.*/* (two-part TLD: .co.uk, .co.jp, ...)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The extension only works on
https://www.google.com/*. On country-specificGoogle domains like
www.google.com.hk,www.google.co.uk,www.google.de,the content script is never injected and the copy feature always fails.
Root Cause
The domain
https://www.google.com/*was hardcoded in 5 locationsacross 2 files:
public/manifest.jsonhost_permissions+content_scripts.matchessrc/background/index.tsdocumentUrlPatterns(context menu)The runtime URL checks (
isAIMode/udm=50query param) were alreadydomain-agnostic — no changes needed there.
Fix
Replaced every occurrence of
https://www.google.com/*with 4 matchpatterns that collectively cover all Google country domains:
This works because Chrome extension match patterns only support
single-label wildcards (
*), so multiple patterns are required tocover both single-TLD domains (
.de,.fr) and two-part TLDs(
.com.hk,.co.uk).Testing
npm run buildsucceedsdomain (test by visiting
https://www.google.com.hk/search?udm=50)