Skip to content

fix: correctly parse '#' in absolute path directory names (fixes #16819)#20877

Closed
shayannab wants to merge 2 commits into
webpack:mainfrom
shayannab:fix-identifier-final
Closed

fix: correctly parse '#' in absolute path directory names (fixes #16819)#20877
shayannab wants to merge 2 commits into
webpack:mainfrom
shayannab:fix-identifier-final

Conversation

@shayannab

Copy link
Copy Markdown
Contributor

Following enhanced-resolve#473 which introduced the \0# escape workaround, this PR implements automatic detection for # in absolute paths to resolve #16819.

The Problem

When a project is located in a directory containing # (e.g. /home/user/test#project/ or C:\my#project\), webpack incorrectly treats # as a fragment identifier, causing resolution failures and UnhandledSchemeError.

The Fix

In _parseResource, if the path is absolute and a / or \ exists after the # before any query string, the # is treated as part of the directory name. Fragments cannot have path separators after them, so this detection is mathematically sound.

Tests Added

  • Linux absolute path with # in directory name
  • Windows absolute path with # in directory name
  • Mixed case with query and fragment after # directory
  • Regression: real fragment on absolute path still detected correctly
  • Regression: relative paths with # fragments unchanged

Copilot AI review requested due to automatic review settings April 26, 2026 05:28
@changeset-bot

changeset-bot Bot commented Apr 26, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8ed4d80

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

webpack-dev-server fails if # in project path

2 participants