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

optimize split_file_uri #570

Merged
merged 1 commit into from
Aug 27, 2018
Merged

Conversation

ahorek
Copy link
Contributor

@ahorek ahorek commented Aug 27, 2018

this gsub is more complicated than it needs to be

related #503

@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @schneems (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@@ -47,14 +47,16 @@ def test_split_file_uri
parts = split_file_uri("file:///usr/local/var/github/app/assets/javascripts/application.js")
assert_equal ['file', nil, '/usr/local/var/github/app/assets/javascripts/application.js', nil], parts

parts = split_file_uri("file:///C:/Documents%20and%20Settings/davris/FileSchemeURIs.doc")
assert_equal ['file', nil, 'C:/Documents and Settings/davris/FileSchemeURIs.doc', nil], parts
if DOSISH
Copy link
Member

Choose a reason for hiding this comment

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

Why we need this conditional now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

file:///C:/ is not a valid uri on linux

Copy link
Member

Choose a reason for hiding this comment

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

Right, but this test was running and passing on linux, so why add the conditional now?

Copy link
Contributor Author

@ahorek ahorek Aug 27, 2018

Choose a reason for hiding this comment

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

the previous version always stripped C: from path

path.gsub!(/^\/([a-zA-Z]:)/, '\1'.freeze)

now we can eliminate this line, because these paths shouldn't exist on nix systems.

windows

file:///C:/Documents

vs nix

file:///usr/local

I need to add guards for these tests. On windows it's still stripped but in a more efficient way

path = path[1..-1]

@rafaelfranca rafaelfranca merged commit 5e075a4 into rails:master Aug 27, 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

4 participants