Better fix for Ruby's URI file:// handling
In a previous pro-tip (https://coderwall.com/p/lk7v1g) I complained about Ruby's URI
module not producing file://...
urls that were widely useful.
I recently had to deal with the problem again but fixed it in a much cleaner way:
require 'uri'
module URI
class FILE < Generic
def to_s
"file://#{path_query}"
end
end
@@schemes['FILE'] = FILE
end
Written by Ryan Graham
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#