Last Updated: February 25, 2016
·
486
· rmg

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