You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(turbopack): Fix a panic when the generated hash is too short when radix formatting a string. (#80966)
## Fix hash length check in metadata formatting
### What?
Fixed a panic in the `format_radix` function when the generated hash is
shorter than 6 characters.
### Why?
The current implementation always tries to take the first 6 characters
of the hash using a fixed slice `result[..6]`, which would panic if the
hash is shorter than 6 characters. This doesn't match the JavaScript
behavior where `toString(36).slice(0, 6)` automatically takes the
minimum of the hash length and 6.
### How?
Added a check to determine the minimum length between the hash length
and 6, then use that value for slicing:
```rust
let len = result.len().min(6);
result[..len].iter().collect()
```
Fixes #PACK-4495
0 commit comments