in extensions/applicationinsights-dependencies-js/src/ajax.ts [564:623]
function _isDisabledRequest(xhr?: XMLHttpRequestInstrumented, request?: Request | string, init?: RequestInit) {
let isDisabled = false;
let theUrl:string = ((!isString(request) ? ((request ||{}) as Request).url || "" : request as string) ||"").toLowerCase();
// check excludeRequestFromAutoTrackingPatterns before stripping off any query string
arrForEach(_excludeRequestFromAutoTrackingPatterns, (regex: string | RegExp) => {
let theRegex = regex;
if (isString(regex)) {
theRegex = new RegExp(regex);
}
if (!isDisabled) {
isDisabled = (theRegex as RegExp).test(theUrl);
}
});
// if request url matches with exclude regex pattern, return true and no need to check for headers
if (isDisabled) {
return isDisabled;
}
let idx = _indexOf(theUrl, "?");
let idx2 = _indexOf(theUrl, "#");
if (idx === -1 || (idx2 !== -1 && idx2 < idx)) {
idx = idx2;
}
if (idx !== -1) {
// Strip off any Query string
theUrl = theUrl.substring(0, idx);
}
// check that this instance is not not used by ajax call performed inside client side monitoring to send data to collector
if (!isNullOrUndefined(xhr)) {
// Look on the XMLHttpRequest of the URL string value
isDisabled = xhr[DisabledPropertyName] === true || theUrl[DisabledPropertyName] === true;
} else if (!isNullOrUndefined(request)) { // fetch
// Look for DisabledPropertyName in either Request or RequestInit
isDisabled = (typeof request === "object" ? request[DisabledPropertyName] === true : false) ||
(init ? init[DisabledPropertyName] === true : false);
}
// Also add extra check just in case the XHR or fetch objects where not decorated with the DisableProperty due to sealing or freezing
if (!isDisabled && theUrl && isInternalApplicationInsightsEndpoint(theUrl)) {
isDisabled = true;
}
if (isDisabled) {
// Add the disabled url if not present
if (!_disabledUrls[theUrl]) {
_disabledUrls[theUrl] = 1;
}
} else {
// Check to see if the url is listed as disabled
if (_disabledUrls[theUrl]) {
isDisabled = true;
}
}
return isDisabled;
}