Skip to content

Conversation

denisx
Copy link
Contributor

@denisx denisx commented May 30, 2024

This PR contains a:

  • bugfix
  • new feature
  • code refactor
  • test update
  • typo fix
  • metadata update

Motivation / Use-Case

To simplify migration from v2 and getting "clean" css classnames, digestType with base64-safe don't contain /, + and = symbols.

Breaking Changes

No

@denisx denisx marked this pull request as ready for review May 30, 2024 18:18
@@ -76,17 +76,19 @@ The following tokens are replaced in the `name` parameter:
- `[contenthash]` the hash of `options.content` (Buffer) (by default it's the hex digest of the `xxhash64` hash)
- `[<hashType>:contenthash:<digestType>:<length>]` optionally one can configure
- other `hashType`s, i. e. `xxhash64`, `sha1`, `md4` (wasm version), `native-md4` (`crypto` module version), `md5`, `sha256`, `sha512`
- other `digestType`s, i. e. `hex`, `base26`, `base32`, `base36`, `base49`, `base52`, `base58`, `base62`, `base64`
- other `digestType`s, i. e. `hex`, `base26`, `base32`, `base36`, `base49`, `base52`, `base58`, `base62`, `base64`, `base64safe`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to base64safe (without -), because regexp in interpolateName can be used in many place and I don't want to change it

return hash.digest(digestType || "hex").substr(0, maxLength);
return encodeBufferToBase(
hash.digest(),
digestType === "base64safe" ? 64 : digestType.substr(4),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also use a table to achieve higher entropy, removing characters can create conflicts, i.e. 3ZWmHo0=hPMWE2rZeN_oHB6 and 3ZWmHo0hPMWE2rZe=N_oHB6 will be same after removing characters, this is bad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants