Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

fix: handle "./.." case #33

Merged
merged 3 commits into from
Oct 8, 2019
Merged

fix: handle "./.." case #33

merged 3 commits into from
Oct 8, 2019

Conversation

jbms
Copy link
Contributor

@jbms jbms commented Dec 25, 2016

Previously, "./../a" was incorrectly transformed to "a". Paths of
that form are sometimes seen by the webpack AliasPlugin.

@jsf-clabot
Copy link

jsf-clabot commented Dec 25, 2016

CLA assistant check
All committers have signed the CLA.

@codecov-io
Copy link

codecov-io commented Dec 25, 2016

Codecov Report

Merging #33 into master will increase coverage by 1.08%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #33      +/-   ##
==========================================
+ Coverage   96.12%   97.21%   +1.08%     
==========================================
  Files           3        3              
  Lines         284      287       +3     
  Branches       65       66       +1     
==========================================
+ Hits          273      279       +6     
+ Misses         11        8       -3
Impacted Files Coverage Δ
lib/normalize.js 89.47% <100%> (+6.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4b96090...322c951. Read the comment docs.

@jbms
Copy link
Contributor Author

jbms commented Dec 29, 2016

Note: While this may seem like an obscure case, it resulted in a failure to find a module that was extremely difficult to track down, due to the many levels of indirection involved.

test/MemoryFileSystem.js Show resolved Hide resolved
@@ -80,7 +85,7 @@ module.exports = function normalize(path) {
result.push(part);
}
}
if(result.length === 1 && /^[A-Za-z]:$/.test(result))
if(result.length === 1 && /^[A-Za-z]:$/.test(result[0]))
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a test for this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I fixed this because passing an array as the argument to test didn't make sense, though in fact it would work since the one element array conversion to string would just equal the string. As far as adding a test case, I can't figure out how to trigger that if statement. None of the existing tests do, and perhaps it is not possible.

Choose a reason for hiding this comment

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

This is not actually a bug fix, but rather a clarity refactor. It's because array to string coercion in JS "just works" for single element arrays:

image

Choose a reason for hiding this comment

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

you can trigger this case by passing in C: as the path.

Choose a reason for hiding this comment

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

fs.normalize("C:").should.be.eql("C:\\");

Previously, "./../a" was incorrectly transformed to "a".  Paths of
that form are sometimes seen by the webpack AliasPlugin.
Copy link

@mikesherov mikesherov left a comment

Choose a reason for hiding this comment

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

Almost there!

@codecov
Copy link

codecov bot commented Sep 18, 2018

Codecov Report

Merging #33 into master will increase coverage by 1.08%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #33      +/-   ##
==========================================
+ Coverage   96.12%   97.21%   +1.08%     
==========================================
  Files           3        3              
  Lines         284      287       +3     
  Branches       65       66       +1     
==========================================
+ Hits          273      279       +6     
+ Misses         11        8       -3
Impacted Files Coverage Δ
lib/normalize.js 89.47% <100%> (+6.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4b96090...322c951. Read the comment docs.

@codecov
Copy link

codecov bot commented Sep 18, 2018

Codecov Report

Merging #33 into master will increase coverage by 1.05%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #33      +/-   ##
==========================================
+ Coverage   96.24%   97.29%   +1.05%     
==========================================
  Files           4        4              
  Lines         293      296       +3     
  Branches       67       68       +1     
==========================================
+ Hits          282      288       +6     
+ Misses         11        8       -3
Impacted Files Coverage Δ
lib/normalize.js 89.47% <100%> (+6.14%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7ae73eb...6666525. Read the comment docs.

@sokra sokra closed this Oct 8, 2019
@sokra sokra reopened this Oct 8, 2019
@sokra sokra merged commit 8a15514 into webpack:master Oct 8, 2019
@sokra
Copy link
Member

sokra commented Oct 8, 2019

Thanks, after nearly 3 years 🎉

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.

5 participants