Skip to content

Commit

Permalink
apply suggestions from review
Browse files Browse the repository at this point in the history
explain regex
  • Loading branch information
minrk committed May 6, 2024
1 parent 5d8f732 commit 61f690c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion binderhub/static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function build(providerSpec, log, fitAddon, path, pathType) {
$(".on-build").removeClass("hidden");

const buildToken = $("#build-token").data("token");
let apiToken = $("#api-token").data("token");
const apiToken = $("#api-token").data("token");
const buildEndpointUrl = new URL("build", BASE_URL);
const image = new BinderRepository(providerSpec, buildEndpointUrl, {
apiToken,
Expand Down
4 changes: 4 additions & 0 deletions js/packages/binderhub-client/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ import { EventIterator } from "event-iterator";

function _getXSRFToken() {
// from @jupyterlab/services
// https://github.com/jupyterlab/jupyterlab/blob/69223102d717f3d3e9f976d32e657a4e2456e85d/packages/services/src/contents/index.ts#L1178-L1184
let cookie = "";
try {
cookie = document.cookie;
} catch (e) {
// e.g. SecurityError in case of CSP Sandbox
return null;
}
// extracts the value of the cookie named `_xsrf`
// by picking up everything between `_xsrf=` and the next semicolon or end-of-line
// `\b` ensures word boundaries, so it doesn't pick up `something_xsrf=`...
const xsrfTokenMatch = cookie.match("\\b_xsrf=([^;]*)\\b");
if (xsrfTokenMatch) {
return xsrfTokenMatch[1];
Expand Down

0 comments on commit 61f690c

Please sign in to comment.