-
-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: add digestType 'base64-safe' #259
Conversation
@@ -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` |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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
This PR contains a:
Motivation / Use-Case
To simplify migration from v2 and getting "clean" css classnames,
digestType
withbase64-safe
don't contain/
,+
and=
symbols.Breaking Changes
No