Skip to content

Commit

Permalink
Escape @ in component definition paths (#29611)
Browse files Browse the repository at this point in the history
Escape @ and the rest of ASCII in component definition paths.

GitOrigin-RevId: 045e3629bea35730f9ed07f3ba74f64eada9638d
  • Loading branch information
thomasballinger authored and Convex, Inc. committed Sep 6, 2024
1 parent df462a4 commit dc49dba
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/cli/lib/components/definition/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,10 @@ export function encodeDefinitionPath(
const components = s.split(path.sep);
return components
.map((s) => {
const escaped = s
.replaceAll("-", "_")
.replaceAll("+", "_")
.replaceAll(" ", "_")
.replaceAll(".", "_");
// some important characters to escape include @-+ .
const escaped = s.replace(/[^a-zA-Z0-9_]/g, "_");
if (escaped.length <= 64 && escaped === s) {
// If escaping lost any information then
// If escaping lost no information then use orig.
return escaped;
}
const hash = crypto.createHash("md5").update(s).digest("hex");
Expand Down

0 comments on commit dc49dba

Please sign in to comment.