nsarrazin HF Staff commited on
Commit
1f110a3
·
1 Parent(s): be1f03e

fix(tools): regex validation

Browse files
src/lib/server/tools/index.ts CHANGED
@@ -72,7 +72,7 @@ export const editableToolSchema = z
72
  name: z.string().min(1).max(40),
73
  // only allow huggingface spaces either through namespace or direct URLs
74
  baseUrl: z.union([
75
- z.string().regex(/^[a-zA-Z0-9-]+\/[a-zA-Z0-9-]+$/),
76
  z
77
  .string()
78
  .regex(/^https:\/\/huggingface\.co\/spaces\/[a-zA-Z0-9-]+\/[a-zA-Z0-9-]+$/)
 
72
  name: z.string().min(1).max(40),
73
  // only allow huggingface spaces either through namespace or direct URLs
74
  baseUrl: z.union([
75
+ z.string().regex(/^[^/]+\/[^/]+$/),
76
  z
77
  .string()
78
  .regex(/^https:\/\/huggingface\.co\/spaces\/[a-zA-Z0-9-]+\/[a-zA-Z0-9-]+$/)
src/routes/api/spaces-config/+server.ts CHANGED
@@ -15,7 +15,7 @@ export async function GET({ url, locals }) {
15
  let namespace = null;
16
  if (space.startsWith("https://huggingface.co/spaces/")) {
17
  namespace = space.split("/").slice(-2).join("/");
18
- } else if (space.match(/^[a-zA-Z0-9-]+\/[a-zA-Z0-9-]+$/)) {
19
  namespace = space;
20
  }
21
 
 
15
  let namespace = null;
16
  if (space.startsWith("https://huggingface.co/spaces/")) {
17
  namespace = space.split("/").slice(-2).join("/");
18
+ } else if (space.match(/^[^/]+\/[^/]+$/)) {
19
  namespace = space;
20
  }
21