Skip to content

Commit

Permalink
fix(session/container): emails with special characters can now be used
Browse files Browse the repository at this point in the history
see issue #6
  • Loading branch information
tuta-amb authored May 16, 2024
1 parent ffea405 commit de8be5d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib/session/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getAuthSession } from "../auth";
import { revalidatePath } from "next/cache";
import { consola } from "consola";
const getRandomNumber = (min: number, max: number) => Math.floor(Math.random() * (max - min + 1)) + min;
const encodeEmailLocal = (email: string) => Array.from(email).map(char => /[a-zA-Z0-9_.-]/.test(char) ? char : char.charCodeAt(0)).join("");
/**
* Creates a new Stardust session
* @param Image Docker image to use for making the session
Expand All @@ -32,7 +33,7 @@ async function createSession(Image: string) {
}
const container = await docker
.createContainer({
name: `stardust-${Date.now()}-${userSession.user.email?.split("@")[0]}`,
name: `stardust-${Date.now()}-${encodeEmailLocal(userSession.user.email?.split("@")[0])}`,
Image,
HostConfig: {
PortBindings: {
Expand Down

0 comments on commit de8be5d

Please sign in to comment.