Skip to content

Commit

Permalink
fix(deps): update dependency netlify-redirect-parser to v10 (#3164)
Browse files Browse the repository at this point in the history
* fix(deps): update dependency netlify-redirect-parser to v10

* chore: fix new major release of `netlify-redirect-parser`

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: ehmicky <ehmicky@gmail.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: ehmicky <ehmicky@users.noreply.github.com>
  • Loading branch information
5 people authored Aug 13, 2021
1 parent b459f51 commit 17a600b
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 15 deletions.
39 changes: 32 additions & 7 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@
"minimist": "^1.2.5",
"multiparty": "^4.2.1",
"netlify": "^8.0.0",
"netlify-redirect-parser": "^9.1.0",
"netlify-redirect-parser": "^10.0.0",
"netlify-redirector": "^0.2.1",
"node-fetch": "^2.6.0",
"node-version-alias": "^1.0.1",
Expand Down
28 changes: 21 additions & 7 deletions src/utils/rules-proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,28 @@ const { NETLIFYDEVWARN, NETLIFYDEVLOG } = require('./logo')
// Parse, normalize and validate all redirects from `_redirects` files
// and `netlify.toml`
const parseRedirectRules = async function ({ redirectsFiles, configPath }) {
try {
const rules = await parseAllRedirects({ redirectsFiles, netlifyConfigPath: configPath, minimal: false })
return rules.map(normalizeRule)
} catch (error) {
console.error(`${NETLIFYDEVWARN} Warnings while parsing redirects:
${error.message}`)
return []
const { redirects, errors } = await parseAllRedirects({
redirectsFiles,
netlifyConfigPath: configPath,
minimal: false,
})
handleRedirectParsingErrors(errors)
return redirects.map(normalizeRule)
}

const handleRedirectParsingErrors = function (errors) {
if (errors.length === 0) {
return
}

const errorMessage = errors.map(getErrorMessage).join('\n\n')
console.error(`${NETLIFYDEVWARN} Warnings while parsing redirects:
${errorMessage}`)
}

const getErrorMessage = function ({ message }) {
return message
}

// `netlify-redirector` does not handle the same shape as the backend:
Expand Down

1 comment on commit 17a600b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 Benchmark results

Package size: 330 MB

Please sign in to comment.