fix: dots in island + route name not working (#2105)

This commit is contained in:
Marvin Hagemeister
2023-11-30 18:14:59 +01:00
committed by GitHub
parent a0483bc357
commit 054ffbb44a
7 changed files with 54 additions and 21 deletions
+2 -20
View File
@@ -1,7 +1,4 @@
import {
isIdentifierChar,
isIdentifierStart,
} from "../server/init_safe_deps.ts";
import { stringToIdentifier } from "../server/init_safe_deps.ts";
import { extname, join, normalize } from "./deps.ts";
/**
@@ -26,22 +23,7 @@ export function specifierToIdentifier(specifier: string, used: Set<string>) {
if (ext) specifier = specifier.slice(0, -ext.length);
// Turn the specifier into a readable JS identifier
let ident = "";
for (let i = 0; i < specifier.length; i++) {
const char = specifier.charCodeAt(i);
if (i === 0 && !isIdentifierStart(char)) {
ident += "_";
if (isIdentifierChar(char)) {
ident += specifier[i];
}
} else if (!isIdentifierChar(char)) {
if (ident[ident.length - 1] !== "_") {
ident += "_";
}
} else if (ident[ident.length - 1] !== "_" || specifier[i] !== "_") {
ident += specifier[i];
}
}
let ident = stringToIdentifier(specifier);
if (used.has(ident)) {
let check = ident;