Skip to content

Commit

Permalink
filters: fixes querystring
Browse files Browse the repository at this point in the history
  • Loading branch information
dresende committed Aug 16, 2024
1 parent a8c5c29 commit b54bb18
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion core/Filters.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import querystring from "querystring";

export const Filters = {};

// convert \n to <br>
Expand All @@ -17,5 +19,5 @@ Filters.json = (json, indent = 8) => {

// print query string encoded object
Filters.qs = (obj, sep = "&", eq = "=") => {
return require("querystring").stringify(obj, sep, eq);
return querystring.stringify(obj, sep, eq);
};
6 changes: 6 additions & 0 deletions test/Filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,10 @@ describe("Filters", () => {

view().should.equal(JSON.stringify({ x: 2 }, null, 8));
});

it("qs", async () => {
const view = await keikan.compileData("<%-: { x: 2, y: 3 } | qs %>");

view().should.equal("x=2&y=3");
});
});

0 comments on commit b54bb18

Please sign in to comment.