Skip to content

Commit d9e1a96

Browse files
mani3xisMariusz Pasinski
andauthored
fix: escape package name (see #127) (#128)
This change fixes [#127](#127) by simply escaping (i.e. replacing) all non-alphanumeric characters with `-` (including `-` itself). While the `escapePath()` is overly strict (e.g. does not allow a valid `_` character) it does not need relaxing for now. Lifting limitations is always backwards-compatible; introducing them is not. Co-authored-by: Mariusz Pasinski <[email protected]>
1 parent c6638e5 commit d9e1a96

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/host/src/node/path-utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,10 @@ export function escapePath(modulePath: string) {
148148
*/
149149
export function getLibraryName(modulePath: string, naming: NamingStrategy) {
150150
const { packageName, relativePath } = determineModuleContext(modulePath);
151+
const escapedPackageName = escapePath(packageName);
151152
return naming.stripPathSuffix
152-
? packageName
153-
: `${packageName}--${escapePath(relativePath)}`;
153+
? escapedPackageName
154+
: `${escapedPackageName}--${escapePath(relativePath)}`;
154155
}
155156

156157
export function prettyPath(p: string) {

0 commit comments

Comments
 (0)