Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow spaces in filenames #1212

Merged
merged 12 commits into from Apr 29, 2018
Merged

Allow spaces in filenames #1212

merged 12 commits into from Apr 29, 2018

Conversation

DeMoorJasper
Copy link
Member

Closes #873

@codecov-io
Copy link

codecov-io commented Apr 18, 2018

Codecov Report

Merging #1212 into master will decrease coverage by 1.83%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1212      +/-   ##
==========================================
- Coverage   88.28%   86.45%   -1.84%     
==========================================
  Files          77       77              
  Lines        4355     4113     -242     
==========================================
- Hits         3845     3556     -289     
- Misses        510      557      +47
Impacted Files Coverage Δ
src/assets/HTMLAsset.js 87.12% <100%> (-1.99%) ⬇️
src/Asset.js 100% <100%> (ø) ⬆️
src/transforms/htmlnano.js 72.22% <0%> (-27.78%) ⬇️
src/visitors/fs.js 57.63% <0%> (-23.62%) ⬇️
src/transforms/posthtml.js 84.37% <0%> (-15.63%) ⬇️
src/visitors/dependencies.js 81.52% <0%> (-13.05%) ⬇️
src/workerfarm/errorUtils.js 70.58% <0%> (-11.77%) ⬇️
src/transforms/babel.js 88.05% <0%> (-7.47%) ⬇️
src/visitors/globals.js 92.3% <0%> (-3.85%) ⬇️
... and 18 more

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 bb7f4aa...fce3e91. Read the comment docs.

src/Resolver.js Outdated
@@ -27,7 +27,7 @@ class Resolver {
}

async resolve(input, parent) {
let filename = input;
let filename = decodeURIComponent(input);
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is the right place to do this. We should only decode when we know that the input is a URL. For example, you could legitimately have a filename called "my%20file" where %20 is not a space.

I think we should do this in addURLDependency where we know the input is supposed to be a URL. Note that we already handled this for HTML assets, so we should move that call into addURLDependency itself so that it applies to e.g. CSS as well. https://github.com/parcel-bundler/parcel/blob/master/src/assets/HTMLAsset.js#L90

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed it in the latest commit, now it supports url encoded files from any asset, and doesn't pass url encoded strings to asset.dependencies

src/Asset.js Outdated
const resolved = path.resolve(path.dirname(from), parsed.pathname);
this.addDependency(
'./' + path.relative(path.dirname(this.name), resolved),
'./' +
path.relative(path.dirname(this.name), decodeURIComponent(resolved)),
Copy link
Member

Choose a reason for hiding this comment

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

wouldn't resolved already be decoded here?

Copy link
Member Author

Choose a reason for hiding this comment

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

URL.parse url encodes the parsed string.
I've pushed a fix as originally I thought the parsed url's encoding was important (therefore decoding twice), but it isn't as we create new filenames anyway.
Now it only decodes once saving some ms of building.

@devongovett devongovett merged commit fb6912d into master Apr 29, 2018
@devongovett devongovett deleted the fix-spaces-in-filenames branch April 29, 2018 14:23
devongovett pushed a commit that referenced this pull request Oct 15, 2018
devongovett pushed a commit that referenced this pull request Oct 15, 2018
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.

None yet

3 participants