package.build.esm.utils.isSentryRequestUrl.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
Base implementation for all Sentry JavaScript SDKs
/**
* Checks whether given url points to Sentry server
*
* @param url url to verify
*/
function isSentryRequestUrl(url, client) {
const dsn = client && client.getDsn();
const tunnel = client && client.getOptions().tunnel;
return checkDsn(url, dsn) || checkTunnel(url, tunnel);
}
function checkTunnel(url, tunnel) {
if (!tunnel) {
return false;
}
return removeTrailingSlash(url) === removeTrailingSlash(tunnel);
}
function checkDsn(url, dsn) {
return dsn ? url.includes(dsn.host) : false;
}
function removeTrailingSlash(str) {
return str[str.length - 1] === '/' ? str.slice(0, -1) : str;
}
export { isSentryRequestUrl };
//# sourceMappingURL=isSentryRequestUrl.js.map