Skip to content

Commit

Permalink
Escape space and parenthesis in Chrome binary path when using JRuby o…
Browse files Browse the repository at this point in the history
…n Windows. Fixes titusfortner#130.
  • Loading branch information
kapoorlakshya committed Jun 8, 2019
1 parent 76e9e37 commit a191005
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/webdrivers/chrome_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ def win_location
directories.each do |dir|
envs.each do |root|
option = "#{ENV[root]}\\#{dir}\\#{file}"
return option if File.exist?(option)
if File.exist?(option) # rubocop:disable Style/Next
return jruby_path(option) if RUBY_PLATFORM == 'java'

return option
end
end
end
end
Expand Down Expand Up @@ -64,6 +68,16 @@ def linux_version(location)
def mac_version(location)
System.call("#{Shellwords.escape location} --version")&.strip
end

private

# Escapes spaces and parentheses in given path
# for JRuby on Windows. Fixes #41 and #130.
def jruby_path(path)
path.gsub(' ', '` ')
.gsub('(', '`(')
.gsub(')', '`)')
end
end
end
end

0 comments on commit a191005

Please sign in to comment.