Skip to content

Commit 3467a70

Browse files
committed
Use upstream prerendercloud lib for detecting HTML paths
1 parent 2aecd72 commit 3467a70

File tree

3 files changed

+5
-28
lines changed

3 files changed

+5
-28
lines changed

lib/util.js

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,7 @@ const parseUriField = uri => {
1616
return JSON.parse(fromBase64(uri.slice(1)));
1717
};
1818

19-
const isHtml = urlStr => {
20-
const parsedUrl = url.parse(urlStr);
21-
const path = parsedUrl.pathname;
22-
const basename = path.split("/").pop();
23-
24-
if (basename === "") return true;
25-
26-
// doesn't detect index.whatever.html (multiple dots)
27-
const hasHtmlOrNoExtension = !!basename.match(/^(([^.]|\.html?)+)$/);
28-
29-
if (hasHtmlOrNoExtension) return true;
30-
31-
// hack to handle basenames with multiple dots: index.whatever.html
32-
const endsInHtml = !!basename.match(/.html?$/);
33-
34-
if (endsInHtml) return true;
35-
36-
// hack to detect extensions that are not HTML so we can handle
37-
// paths with dots in them
38-
const endsInOtherExtension = basename.match(/\.[a-zA-Z]{1,5}$/);
39-
if (!endsInOtherExtension) return true;
40-
41-
return false;
42-
};
19+
const isHtml = require("prerendercloud").util.urlPathIsHtml;
4320

4421
module.exports = {
4522
USER_AGENT_PLACEHOLDER,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
"serverless": "1.24.1"
77
},
88
"dependencies": {
9-
"prerendercloud": "^1.23.2"
9+
"prerendercloud": "1.27.0"
1010
}
1111
}

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,9 +1300,9 @@ prepend-http@^2.0.0:
13001300
version "2.0.0"
13011301
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-2.0.0.tgz#e92434bfa5ea8c19f41cdfd401d741a3c819d897"
13021302

1303-
prerendercloud@^1.23.2:
1304-
version "1.23.2"
1305-
resolved "https://registry.yarnpkg.com/prerendercloud/-/prerendercloud-1.23.2.tgz#297981b968b0944143b6915a91fce258964a3933"
1303+
prerendercloud@1.27.0:
1304+
version "1.27.0"
1305+
resolved "https://registry.yarnpkg.com/prerendercloud/-/prerendercloud-1.27.0.tgz#992c64a1420aeb20c02b2c19dd740d64a5ad8cff"
13061306
dependencies:
13071307
debug "^2.2.0"
13081308
got-lite "^8.0.1"

0 commit comments

Comments
 (0)