gatsby-page-utils
Advanced tools
Comparing version 3.12.0-next.1 to 3.13.0-next.0
@@ -5,15 +5,20 @@ "use strict"; | ||
exports.applyTrailingSlashOption = void 0; | ||
const endsWithSuffixes = (suffixes, input) => { | ||
for (const suffix of suffixes) { | ||
if (input.endsWith(suffix)) return true; | ||
} | ||
return false; | ||
}; | ||
const suffixes = [`.html`, `.json`, `.js`, `.map`, `.txt`, `.xml`, `.pdf`]; | ||
const applyTrailingSlashOption = (input, option = `always`) => { | ||
const hasHtmlSuffix = input.endsWith(`.html`); | ||
const hasXmlSuffix = input.endsWith(`.xml`); | ||
const hasPdfSuffix = input.endsWith(`.pdf`); | ||
if (input === `/`) return input; | ||
if (hasHtmlSuffix || hasXmlSuffix || hasPdfSuffix) { | ||
option = `never`; | ||
const hasTrailingSlash = input.endsWith(`/`); | ||
if (endsWithSuffixes(suffixes, input)) { | ||
return input; | ||
} | ||
if (option === `always`) { | ||
return input.endsWith(`/`) ? input : `${input}/`; | ||
return hasTrailingSlash ? input : `${input}/`; | ||
} | ||
if (option === `never`) { | ||
return input.endsWith(`/`) ? input.slice(0, -1) : input; | ||
return hasTrailingSlash ? input.slice(0, -1) : input; | ||
} | ||
@@ -20,0 +25,0 @@ return input; |
{ | ||
"name": "gatsby-page-utils", | ||
"version": "3.12.0-next.1", | ||
"version": "3.13.0-next.0", | ||
"description": "Gatsby library that helps creating pages", | ||
@@ -33,3 +33,3 @@ "main": "dist/index.js", | ||
"fs-exists-cached": "^1.0.0", | ||
"gatsby-core-utils": "^4.12.0-next.1", | ||
"gatsby-core-utils": "^4.13.0-next.0", | ||
"glob": "^7.2.3", | ||
@@ -43,3 +43,3 @@ "lodash": "^4.17.21", | ||
"@types/micromatch": "^4.0.2", | ||
"babel-preset-gatsby-package": "^3.12.0-next.0", | ||
"babel-preset-gatsby-package": "^3.13.0-next.0", | ||
"cross-env": "^7.0.3", | ||
@@ -55,3 +55,3 @@ "rimraf": "^5.0.1", | ||
}, | ||
"gitHead": "1ebae562b846165da217da3ee726b3201909f9a1" | ||
"gitHead": "e6e2fb4fddd1f076531b01ea2bd6fe4f43655f8c" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56398
151