-
Notifications
You must be signed in to change notification settings - Fork 5
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
Allow localhost URLs when detecting write key #38
Conversation
@@ -1,7 +1,7 @@ | |||
import { embeddedWriteKey } from './embedded-write-key' | |||
|
|||
const analyticsScriptRegex = | |||
/(https:\/\/[\w.-]+)\/(?:analytics\.js\/v1|v1\/analytics-js\/snippet)\/[\w-:]+\/(analytics\.(?:min)\.js)/ | |||
/(https?:\/\/[\w.\-:]+)\/(?:analytics\.js\/v1|v1\/analytics-js\/snippet)\/[\w\-:]+\/(analytics\.(?:min)\.js)/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Escaped the -
in the latter part of the regex because it wasn't a range. We intended to allow a dash -
[\w\-:]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not relevant to your PR, but I'm not really sure what the (?:min)
bit at the end is doing. Non-capturing match on min
seems pointless.
I wonder if it's supposed to be optionally matching .min
in the path, in which case:
(analytics\.(?:min)\.js)
should probably be:
(?:analytics(\.min)?\.js)
Just to confirm that our CDN redirects HTTP to HTTPS:
|
@@ -1,7 +1,7 @@ | |||
import { embeddedWriteKey } from './embedded-write-key' | |||
|
|||
const analyticsScriptRegex = | |||
/(https:\/\/[\w.-]+)\/(?:analytics\.js\/v1|v1\/analytics-js\/snippet)\/[\w-:]+\/(analytics\.(?:min)\.js)/ | |||
/(https?:\/\/[\w.\-:]+)\/(?:analytics\.js\/v1|v1\/analytics-js\/snippet)\/[\w\-:]+\/(analytics\.(?:min)\.js)/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not relevant to your PR, but I'm not really sure what the (?:min)
bit at the end is doing. Non-capturing match on min
seems pointless.
I wonder if it's supposed to be optionally matching .min
in the path, in which case:
(analytics\.(?:min)\.js)
should probably be:
(?:analytics(\.min)?\.js)
Useful for local testing.
This PR allows
http://
URLs to be used when extracting the CDN. I considered possible security implications but quickly dismissed it because:analytics.min.js
file themselves, allowinghttp://
URLs is useful for local testing.