Skip to content

refactor(utils): parsepackagestring crashes on undefined packagestring#972

Open
LucciHank wants to merge 1 commit intopastelsky:bundlephobiafrom
LucciHank:contribai/improve/quality/parsepackagestring-crashes-on-undefined-
Open

refactor(utils): parsepackagestring crashes on undefined packagestring#972
LucciHank wants to merge 1 commit intopastelsky:bundlephobiafrom
LucciHank:contribai/improve/quality/parsepackagestring-crashes-on-undefined-

Conversation

@LucciHank
Copy link
Copy Markdown

Description

When ctx.query.package is absent, packageQuery is undefined. Calling parsePackageString(undefined) does undefined.lastIndexOf which throws TypeError. This crashes the exports/exportSizes middleware on any request missing the package query param (or malformed requests), taking down the response.

Changes

  • utils/common.utils.js (modified)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Testing

  • Code follows the style guidelines of this project
  • Self-review of code completed
  • Changes generate no new warnings
  • Corresponding changes to documentation made (if applicable)

Severity: high

Contributed by Lê Thành Chỉnh
Code is a tool. Mindset is the real value.

Closes #971

When ctx.query.package is absent, packageQuery is undefined. Calling parsePackageString(undefined) does `undefined.lastIndexOf` which throws TypeError. This crashes the exports/exportSizes middleware on any request missing the package query param (or malformed requests), taking down the response.

Affected files: common.utils.js

Signed-off-by: Hoangg Anh <131897682+LucciHank@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: parsepackagestring crashes on undefined packagestring

1 participant