Skip to content

fix(gatsby-source-filesystem): url pathname can be null, causing path.parse to throw in filesystem utils #39532

@Nam0101

Description

@Nam0101

Description

getParsedPath calls path.parse(Url.parse(url).pathname) without a null fallback. For malformed/edge URL inputs where pathname is null, path.parse throws a TypeError, which can crash callers like getRemoteFileExtension/getRemoteFileName. The TypeScript equivalent in gatsby-core-utils already guards this with || '', indicating this JS version is less safe.

Severity: medium
File: packages/gatsby-source-filesystem/src/utils.js

Expected Behavior

The code should handle this case properly to avoid unexpected errors or degraded quality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    status: triage neededIssue or pull request that need to be triaged and assigned to a reviewer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions