Skip to content

Commit cdd27d8

Browse files
committed
Update connector.ts
1 parent f4f1d76 commit cdd27d8

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

packages/laravel-echo/src/connector/connector.ts

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -90,25 +90,14 @@ export abstract class Connector<
9090
* Extract the CSRF token from the page.
9191
*/
9292
protected csrfToken(): null | string {
93-
let selector;
94-
95-
if (window?.Laravel?.csrfToken) {
96-
return window.Laravel.csrfToken;
97-
}
98-
99-
if (this.options.csrfToken) {
100-
return this.options.csrfToken;
101-
}
102-
103-
if (
104-
typeof document !== "undefined" &&
105-
typeof document.querySelector === "function" &&
106-
(selector = document.querySelector('meta[name="csrf-token"]'))
107-
) {
108-
return selector.getAttribute("content");
109-
}
110-
111-
return null;
93+
return (
94+
window?.Laravel?.csrfToken ??
95+
this.options.csrfToken ??
96+
document
97+
?.querySelector('meta[name="csrf-token"]')
98+
?.getAttribute("content") ??
99+
null
100+
);
112101
}
113102

114103
/**

0 commit comments

Comments
 (0)