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

Regex comments for host detection #10

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion modules/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,29 @@ var healthCheckCounterEnum = Object.freeze({
var SDK_VERSION = "23.12.4";
var SDK_NAME = "javascript_native_web";

// Using this on document.referrer would return an array with 15 elements in it. The 12th element (array[11]) would be the path we are looking for. Others would be things like password and such (use https://regex101.com/ to check more)
// Using this on document.referrer would return an array with 17 elements in it. The 12th element (array[11]) would be the path we are looking for. Others would be things like password and such (use https://regex101.com/ to check more)
// an example URL:
// http://user:pass@host:8080/path/to/resource?query=value#fragment
// this url would yield the following result for matches = urlParseRE.exec(document.referrer);
//
// 0: "http://user:pass@host:8080/path/to/resource?query=value#fragment"
// 1: "http://user:pass@host:8080/path/to/resource?query=value"
// 2: "http://user:pass@host:8080/path/to/resource"
// 3: "http://user:pass@host:8080"
// 4: "http:"
// 5: "//"
// 6: "user:pass@host:8080"
// 7: "user:pass"
// 8: "user"
// 9: "pass"
// 10: "host:8080"
// 11: "host"
// 12: "8080"
// 13: "/path/to/resource"
// 14: "/path/to/"
// 15: "resource"
// 16: "?query=value"
// 17: "#fragment"
var urlParseRE = /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;

export { CDN, DeviceIdTypeInternalEnums, SDK_NAME, SDK_VERSION, configurationDefaultValues, featureEnums, healthCheckCounterEnum, internalEventKeyEnums, internalEventKeyEnumsArray, logLevelEnums, urlParseRE };
Loading