@sentry/api 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.js CHANGED
@@ -1,12 +1,10 @@
1
1
  // src/browser-client.ts
2
- var SAFE_METHODS = new Set(["GET", "HEAD", "OPTIONS", "TRACE"]);
2
+ var SAFE_METHODS = /* @__PURE__ */ new Set(["GET", "HEAD", "OPTIONS", "TRACE"]);
3
3
  function readCookie(name) {
4
- if (typeof document === "undefined")
5
- return "";
4
+ if (typeof document === "undefined") return "";
6
5
  const escapedName = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
7
6
  const match = document.cookie.match(new RegExp(`(?:^|; )${escapedName}=([^;]*)`));
8
- if (!match)
9
- return "";
7
+ if (!match) return "";
10
8
  try {
11
9
  return decodeURIComponent(match[1]);
12
10
  } catch {
@@ -17,11 +15,12 @@ function createBrowserFetch(opts = {}) {
17
15
  const getCsrf = opts.getCsrfToken ?? (() => readCookie(opts.csrfCookieName ?? "sc"));
18
16
  return (input, init) => {
19
17
  const method = (init?.method ?? (input instanceof Request ? input.method : "GET")).toUpperCase();
20
- const headers = new Headers(init?.headers ?? (input instanceof Request ? input.headers : undefined));
18
+ const headers = new Headers(
19
+ init?.headers ?? (input instanceof Request ? input.headers : void 0)
20
+ );
21
21
  if (!SAFE_METHODS.has(method)) {
22
22
  const token = getCsrf();
23
- if (token)
24
- headers.set("X-CSRFToken", token);
23
+ if (token) headers.set("X-CSRFToken", token);
25
24
  }
26
25
  return globalThis.fetch(input, { ...init, headers, credentials: "include" });
27
26
  };
@@ -33,6 +32,6 @@ function createBrowserSdkConfig(opts = {}) {
33
32
  };
34
33
  }
35
34
  export {
36
- createBrowserSdkConfig,
37
- createBrowserFetch
35
+ createBrowserFetch,
36
+ createBrowserSdkConfig
38
37
  };