Skip to content

Commit

Permalink
Fixes #1988
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Sep 28, 2021
1 parent 508114a commit 261958d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@
"mustache": "^4.2.0",
"normalize-path": "^3.0.0",
"nunjucks": "^3.2.3",
"path-to-regexp": "^6.2.0",
"please-upgrade-node": "^3.2.0",
"pretty": "^2.0.0",
"pug": "^3.0.2",
"recursive-copy": "^2.0.13",
"semver": "^7.3.5",
"slugify": "^1.6.0",
"split": "^1.0.1",
"time-require": "^0.1.2",
"url-pattern": "^1.0.3"
"time-require": "^0.1.2"
}
}
6 changes: 3 additions & 3 deletions src/Filters/ServerlessUrl.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const UrlPattern = require("url-pattern");
const { compile } = require("path-to-regexp");

function stringify(url, urlData = {}) {
let pattern = new UrlPattern(url);
return pattern.stringify(urlData);
let fn = compile(url, { encode: encodeURIComponent });
return fn(urlData);
}

module.exports = function (url, urlData = {}) {
Expand Down
8 changes: 4 additions & 4 deletions src/Serverless.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const fs = require("fs");

const Eleventy = require("./Eleventy");
const TemplatePath = require("./TemplatePath");
const UrlPattern = require("url-pattern");
const { match } = require("path-to-regexp");
const deleteRequireCache = require("./Util/DeleteRequireCache");
const debug = require("debug")("Eleventy:Serverless");

Expand Down Expand Up @@ -40,8 +40,8 @@ class Serverless {
inputDir: null, // override only, we now inject this.
functionsDir: "functions/",
matchUrlToPattern(path, urlToCompare) {
let pattern = new UrlPattern(urlToCompare);
return pattern.match(path);
let fn = match(urlToCompare, { decode: decodeURIComponent });
return fn(path);
},
// Query String Parameters
query: {},
Expand Down Expand Up @@ -131,7 +131,7 @@ class Serverless {
if (result) {
matches.push({
compareTo: url,
pathParams: result,
pathParams: result.params,
inputPath: contentMap[url],
});
}
Expand Down

0 comments on commit 261958d

Please sign in to comment.