Skip to content

Commit

Permalink
Stop using URI.escape and start using URI::Parser
Browse files Browse the repository at this point in the history
This fixes a part of the #322 issue.
  • Loading branch information
etagwerker committed Nov 4, 2021
1 parent 1ffbcdf commit e90fda4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/metric_fu/formatter/html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ def open_in_browser?
# The directory path where the 'index.html' we want to open is
# stored
def show_in_browser(dir)
uri = URI.join(URI.escape("file://#{dir}/"), "index.html")
parser = URI::Parser.new
uri = URI.join(parser.escape("file://#{dir}/"), "index.html")
Launchy.open(uri) if open_in_browser?
end
end
Expand Down
6 changes: 4 additions & 2 deletions spec/metric_fu/formatter/html_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ def directory(name)
allow(MetricFu.configuration).to receive(:is_cruise_control_rb?).and_return(false)
formatter = MetricFu::Formatter::HTML.new
path = MetricFu.run_path.join(directory("output_directory"))
uri = URI.join(URI.escape("file://#{path}/"), "index.html")
parser = URI::Parser.new
uri = URI.join(parser.escape("file://#{path}/"), "index.html")
expect(Launchy).to receive(:open).with(uri)
formatter.finish
formatter.display_results
Expand Down Expand Up @@ -125,7 +126,8 @@ def directory(name)
allow(MetricFu.configuration).to receive(:is_cruise_control_rb?).and_return(false)
formatter = MetricFu::Formatter::HTML.new(output: @output)
path = MetricFu.run_path.join("#{directory('base_directory')}/#{@output}")
uri = URI.join(URI.escape("file://#{path}/"), "index.html")
parser = URI::Parser.new
uri = URI.join(parser.escape("file://#{path}/"), "index.html")
expect(Launchy).to receive(:open).with(uri)
formatter.finish
formatter.display_results
Expand Down

0 comments on commit e90fda4

Please sign in to comment.