Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: allow interpolateName works without options
  • Loading branch information
alexander-akait committed Oct 20, 2021
1 parent f37156e commit 862ea7d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/interpolateName.js
Expand Up @@ -3,7 +3,7 @@
const path = require("path");
const getHashDigest = require("./getHashDigest");

function interpolateName(loaderContext, name, options) {
function interpolateName(loaderContext, name, options = {}) {
let filename;

const hasQuery =
Expand Down
9 changes: 4 additions & 5 deletions test/interpolateName.test.js
Expand Up @@ -263,12 +263,11 @@ describe("interpolateName()", () => {
],
]);

it("should return the same emoji for the same string", () => {
const args = [{}, "[emoji:5]", { content: "same_emoji" }];
const result1 = loaderUtils.interpolateName.apply(loaderUtils, args);
const result2 = loaderUtils.interpolateName.apply(loaderUtils, args);
it("should work without options", () => {
const args = [{}, "foo/bar/[hash]"];
const result = loaderUtils.interpolateName.apply(loaderUtils, args);

expect(result1).toBe(result2);
expect(result).toBe("foo/bar/[hash]");
});

describe("no loader context", () => {
Expand Down

0 comments on commit 862ea7d

Please sign in to comment.