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

Fix Windows path resolution #112

Merged
merged 1 commit into from
Aug 22, 2019
Merged

Fix Windows path resolution #112

merged 1 commit into from
Aug 22, 2019

Conversation

ttung
Copy link
Collaborator

@ttung ttung commented Jul 27, 2019

When extracting the path component from urllib.parse.urlparse, the path always starts with '/'. When tokenizing the url into its components, it becomes '/', 'c:', 'windows', 'system32'. Unfortunately, when combined into a WindowsPath, it becomes 'c:windows/system32', which honestly makes no sense to me.

The approach here is to strip the prefix '/', and when we do that, WindowsPath can parse the posix path correctly.

Thanks to @dany-fu for reporting this.

Test plan: loaded up a very empty experiment.json on a Windows VM.

When extracting the path component from urllib.parse.urlparse, the path always starts with '/'.  When tokenizing the url into its components, it becomes '/', 'c:', 'windows', 'system32'.  Unfortunately, when combined into a WindowsPath, it becomes 'c:windows/system32', which honestly makes no sense to me.

The approach here is to strip the prefix '/', and when we do that, WindowsPath can parse the posix path correctly.

Test plan: Ran this on a Windows VM.
@ttung ttung requested a review from shanaxel42 July 27, 2019 06:48
@codecov-io
Copy link

Codecov Report

Merging #112 into master will decrease coverage by 0.08%.
The diff coverage is 66.66%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #112      +/-   ##
==========================================
- Coverage   75.49%   75.41%   -0.09%     
==========================================
  Files          29       29              
  Lines         906      907       +1     
==========================================
  Hits          684      684              
- Misses        222      223       +1
Impacted Files Coverage Δ
slicedimage/url/resolve.py 72.09% <66.66%> (-1.72%) ⬇️

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 ba15786...c37a914. Read the comment docs.

@ttung ttung merged commit dcaaa88 into master Aug 22, 2019
@ttung ttung deleted the tonytung-windows-path branch August 26, 2019 23:40
ttung pushed a commit that referenced this pull request Sep 3, 2019
This is the same issue as #112, so I added a general method to do this conversion.
ttung pushed a commit that referenced this pull request Sep 5, 2019
This is the same issue as #112, so I added a general method to do this conversion.
@ttung ttung mentioned this pull request Sep 5, 2019
ttung pushed a commit that referenced this pull request Sep 5, 2019
This is the same issue as #112, so I added a general method to do this conversion.
ttung pushed a commit that referenced this pull request Sep 5, 2019
This is the same issue as #112, so I added a general method to do this conversion.
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.

3 participants