-
Notifications
You must be signed in to change notification settings - Fork 8
GPT integration #282
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
base: main
Are you sure you want to change the base?
GPT integration #282
Conversation
ChristianPavilonis
commented
Feb 10, 2026
- initi
- simplify
- more proxies
- docs
|
|
||
| /** Google ad-serving domains whose URLs should be proxied (exact match). */ | ||
| const GPT_DOMAINS = [ | ||
| 'securepubads.g.doubleclick.net', |
Check failure
Code scanning / CodeQL
Incomplete regular expression for hostnames High
here
Copilot Autofix
AI about 15 hours ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
| /** Google ad-serving domains whose URLs should be proxied (exact match). */ | ||
| const GPT_DOMAINS = [ | ||
| 'securepubads.g.doubleclick.net', | ||
| 'pagead2.googlesyndication.com', |
Check failure
Code scanning / CodeQL
Incomplete regular expression for hostnames High
here
Copilot Autofix
AI about 15 hours ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
| const GPT_DOMAINS = [ | ||
| 'securepubads.g.doubleclick.net', | ||
| 'pagead2.googlesyndication.com', | ||
| 'tpc.googlesyndication.com', |
Check failure
Code scanning / CodeQL
Incomplete regular expression for hostnames High
here
Copilot Autofix
AI about 15 hours ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
| 'pagead2.googlesyndication.com', | ||
| 'tpc.googlesyndication.com', | ||
| 'googletagservices.com', | ||
| 'www.googletagservices.com', |
Check failure
Code scanning / CodeQL
Incomplete regular expression for hostnames High
here
Copilot Autofix
AI about 15 hours ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
| 'tpc.googlesyndication.com', | ||
| 'googletagservices.com', | ||
| 'www.googletagservices.com', | ||
| 'cm.g.doubleclick.net', |
Check failure
Code scanning / CodeQL
Incomplete regular expression for hostnames High
here
Copilot Autofix
AI about 15 hours ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
| 'cm.g.doubleclick.net', | ||
| 'ep1.adtrafficquality.google', | ||
| 'ep2.adtrafficquality.google', | ||
| 'www.googleadservices.com', |
Check failure
Code scanning / CodeQL
Incomplete regular expression for hostnames High
here
Copilot Autofix
AI about 15 hours ago
Copilot could not generate an autofix suggestion
Copilot could not generate an autofix suggestion for this alert. Try pushing a new commit or if the problem persists contact support.
| if (lower.includes(domain)) { | ||
| const prefix = hostPrefixForDomain(domain); | ||
| return originalUrl.replace( | ||
| new RegExp(`https?://(?:www\\.)?${domain.replace(/\./g, '\\.')}`, 'i'), |
Check failure
Code scanning / CodeQL
Incomplete string escaping or encoding High
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 15 hours ago
In general, when building a regular expression from a string, that string must be fully escaped for regex metacharacters, including the backslash, so that it is treated purely as a literal. Instead of partially escaping only dots with domain.replace(/\./g, '\\.'), we should pass domain through a small helper that escapes all regex special characters (e.g. [.*+?^${}()|[\]\\]) before interpolating into new RegExp(...).
For this file, the best minimal fix is:
- Add a local helper function, e.g.
escapeRegExp, that takes a string and returns it with all regex metacharacters escaped. A standard implementation iss.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'). - Use this helper on
domainwhen constructing theRegExpin the fallback ofrewriteUrl, replacingdomain.replace(/\./g, '\\.')withescapeRegExp(domain). - Place the helper near other utility functions (e.g. after
hostPrefixForDomain) to keep the code organized.
No behavior changes for current hard-coded domains, but the code becomes correct and safe for any future domains.
-
Copy modified lines R83-R89 -
Copy modified line R108
| @@ -80,6 +80,13 @@ | ||
| } | ||
|
|
||
| /** | ||
| * Escape a string so it can be safely used inside a RegExp as a literal. | ||
| */ | ||
| function escapeRegExp(input: string): string { | ||
| return input.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
| } | ||
|
|
||
| /** | ||
| * Rewrite a GPT URL to the first-party proxy, preserving path, query, and | ||
| * fragment. Applies the correct host-prefix for domains that need one. | ||
| */ | ||
| @@ -98,7 +105,7 @@ | ||
| if (lower.includes(domain)) { | ||
| const prefix = hostPrefixForDomain(domain); | ||
| return originalUrl.replace( | ||
| new RegExp(`https?://(?:www\\.)?${domain.replace(/\./g, '\\.')}`, 'i'), | ||
| new RegExp(`https?://(?:www\\.)?${escapeRegExp(domain)}`, 'i'), | ||
| `${window.location.protocol}//${window.location.host}${PROXY_PREFIX}${prefix}`, | ||
| ); | ||
| } |