Skip to content

Commit

Permalink
Merge pull request #10 from Countly/regex
Browse files Browse the repository at this point in the history
Regex comments for host detection
  • Loading branch information
ArtursKadikis authored Jan 29, 2024
2 parents 6ea5556 + e3392d3 commit 4fcdb8f
Showing 1 changed file with 23 additions and 1 deletion.
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 };

0 comments on commit 4fcdb8f

Please sign in to comment.