Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d19e92f

Browse filesBrowse files
refactor!: [emoji] was removed without replacements, please use custom function if you need this
1 parent 93a87ce commit d19e92f
Copy full SHA for d19e92f

File tree

Expand file treeCollapse file tree

4 files changed

+0
-73
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+0
-73
lines changed

‎README.md

Copy file name to clipboardExpand all lines: README.md
-10Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ The following tokens are replaced in the `name` parameter:
150150
- `[path]` the path of the resource relative to the `context` query parameter or option.
151151
- `[folder]` the folder the resource is in
152152
- `[query]` the queryof the resource, i.e. `?foo=bar`
153-
- `[emoji]` a random emoji representation of `options.content`
154-
- `[emoji:<length>]` same as above, but with a customizable number of emojis
155153
- `[contenthash]` the hash of `options.content` (Buffer) (by default it's the hex digest of the md4 hash)
156154
- `[<hashType>:contenthash:<digestType>:<length>]` optionally one can configure
157155
- other `hashType`s, i. e. `sha1`, `md4`, `md5`, `sha256`, `sha512`
@@ -190,14 +188,6 @@ loaderUtils.interpolateName(loaderContext, "html-[hash:6].html", { content: ...
190188
loaderUtils.interpolateName(loaderContext, "[hash]", { content: ... });
191189
// => c31e9820c001c9c4a86bce33ce43b679
192190

193-
// loaderContext.resourcePath = "/absolute/path/to/app/img/image.gif"
194-
loaderUtils.interpolateName(loaderContext, "[emoji]", { content: ... });
195-
// => 👍
196-
197-
// loaderContext.resourcePath = "/absolute/path/to/app/img/image.gif"
198-
loaderUtils.interpolateName(loaderContext, "[emoji:4]", { content: ... });
199-
// => 🙍🏢📤🐝
200-
201191
// loaderContext.resourcePath = "/absolute/path/to/app/img/image.png"
202192
loaderUtils.interpolateName(loaderContext, "[sha512:hash:base64:7].[ext]", { content: ... });
203193
// => 2BKDTjl.png

‎lib/interpolateName.js

Copy file name to clipboardExpand all lines: lib/interpolateName.js
-35Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,8 @@
11
"use strict";
22

33
const path = require("path");
4-
const emojisList = require("emojis-list");
54
const getHashDigest = require("./getHashDigest");
65

7-
const emojiRegex = /[\uD800-\uDFFF]./;
8-
const emojiList = emojisList.filter((emoji) => emojiRegex.test(emoji));
9-
const emojiCache = {};
10-
11-
function encodeStringToEmoji(content, length) {
12-
if (emojiCache[content]) {
13-
return emojiCache[content];
14-
}
15-
16-
length = length || 1;
17-
18-
const emojis = [];
19-
20-
do {
21-
if (!emojiList.length) {
22-
throw new Error("Ran out of emoji");
23-
}
24-
25-
const index = Math.floor(Math.random() * emojiList.length);
26-
27-
emojis.push(emojiList[index]);
28-
emojiList.splice(index, 1);
29-
} while (--length > 0);
30-
31-
const emojiEncoding = emojis.join("");
32-
33-
emojiCache[content] = emojiEncoding;
34-
35-
return emojiEncoding;
36-
}
37-
386
function interpolateName(loaderContext, name, options) {
397
let filename;
408

@@ -111,9 +79,6 @@ function interpolateName(loaderContext, name, options) {
11179
/\[(?:([^:\]]+):)?(?:hash|contenthash)(?::([a-z]+\d*))?(?::(\d+))?\]/gi,
11280
(all, hashType, digestType, maxLength) =>
11381
getHashDigest(content, hashType, digestType, parseInt(maxLength, 10))
114-
)
115-
.replace(/\[emoji(?::(\d+))?\]/gi, (all, length) =>
116-
encodeStringToEmoji(content, parseInt(length, 10))
11782
);
11883
}
11984

‎package.json

Copy file name to clipboardExpand all lines: package.json
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"description": "utils for webpack loaders",
66
"dependencies": {
77
"big.js": "^6.1.1",
8-
"emojis-list": "^3.0.0",
98
"json5": "^2.2.0"
109
},
1110
"scripts": {

‎test/interpolateName.test.js

Copy file name to clipboardExpand all lines: test/interpolateName.test.js
-27Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
const loaderUtils = require("../");
44

5-
const emojiRegex = /[\uD800-\uDFFF]./;
6-
75
describe("interpolateName()", () => {
86
function run(tests) {
97
tests.forEach((test) => {
@@ -273,21 +271,6 @@ describe("interpolateName()", () => {
273271
"[unrecognized]",
274272
"should not interpolate unrecognized token",
275273
],
276-
[
277-
[{}, "[emoji]", { content: "test" }],
278-
(result) => {
279-
expect(emojiRegex.test(result)).toBe(true);
280-
},
281-
"should interpolate [emoji]",
282-
],
283-
[
284-
[{}, "[emoji:3]", { content: "string" }],
285-
(result) => {
286-
expect(emojiRegex.test(result)).toBe(true);
287-
expect(result.length).toBeDefined();
288-
},
289-
"should interpolate [emoji:3]",
290-
],
291274
]);
292275

293276
it("should return the same emoji for the same string", () => {
@@ -298,16 +281,6 @@ describe("interpolateName()", () => {
298281
expect(result1).toBe(result2);
299282
});
300283

301-
it("should throw error when out of emoji", () => {
302-
expect(() => {
303-
loaderUtils.interpolateName.apply(loaderUtils, [
304-
{},
305-
"[emoji:5000]",
306-
{ content: "foo" },
307-
]);
308-
}).toThrow("Ran out of emoji");
309-
});
310-
311284
describe("no loader context", () => {
312285
const loaderContext = {};
313286
run([

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.