Skip to content

moduleNameResolver: fix getCommonPrefix#26305

Merged
sheetalkamat merged 6 commits into
microsoft:masterfrom
ajafff:common-prefix
Aug 10, 2018
Merged

moduleNameResolver: fix getCommonPrefix#26305
sheetalkamat merged 6 commits into
microsoft:masterfrom
ajafff:common-prefix

Conversation

@ajafff
Copy link
Copy Markdown
Contributor

@ajafff ajafff commented Aug 8, 2018

Fixes: #26301

  • Fixes the case where directory is a parent directory of resolution.
  • Also correctly handle root directory if that is the common prefix.
  • Added tests for all the different cases


// find first position where directory and resolution differs
let i = 0;
while (i < Math.min(directory.length, resolutionDirectory.length) && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Prefere original algorithm because it scans the strings only once and gets the mismatch index.. We should handle that index position better rather than changing that algorithm,

@sheetalkamat sheetalkamat merged commit 9ba224d into microsoft:master Aug 10, 2018
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

moduleNameResolver: getCommonPrefix returns wrong path if directory is parent of resolution

2 participants