diff options
-rw-r--r-- | lib/bundler/friendly_errors.rb | 4 | ||||
-rw-r--r-- | spec/bundler/friendly_errors_spec.rb | 20 |
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/bundler/friendly_errors.rb b/lib/bundler/friendly_errors.rb index a01c03f25c..d8c68f552d 100644 --- a/lib/bundler/friendly_errors.rb +++ b/lib/bundler/friendly_errors.rb @@ -89,8 +89,10 @@ module Bundler end def issues_url(exception) + message = exception.message.lines.first.tr(":", " ").chomp + message = message.split("-").first if exception.is_a?(Errno) "https://github.com/bundler/bundler/search?q=" \ - "#{CGI.escape(exception.message.lines.first.chomp)}&type=Issues" + "#{CGI.escape(message)}&type=Issues" end end diff --git a/spec/bundler/friendly_errors_spec.rb b/spec/bundler/friendly_errors_spec.rb index ae197a4bab..cc478ef7a5 100644 --- a/spec/bundler/friendly_errors_spec.rb +++ b/spec/bundler/friendly_errors_spec.rb @@ -2,6 +2,7 @@ require "spec_helper" require "bundler" require "bundler/friendly_errors" +require "cgi" describe Bundler, "friendly errors" do context "with invalid YAML in .gemrc" do @@ -66,5 +67,24 @@ END expect(Bundler::FriendlyErrors.issues_url(exception)).to eq("https://github.com/bundler/bundler/search?q=First+line+of+the+exception+message&type=Issues") end + + it "generates the url without colons" do + exception = Exception.new(<<END) +Exception ::: with ::: colons ::: +END + issues_url = Bundler::FriendlyErrors.issues_url(exception) + expect(issues_url).not_to include("%3A") + expect(issues_url).to eq("https://github.com/bundler/bundler/search?q=#{CGI.escape("Exception with colons ")}&type=Issues") + end + + it "removes information after - for Errono::EACCES" do + exception = Exception.new(<<END) +Errno::EACCES: Permission denied @ dir_s_mkdir - /Users/foo/bar/ +END + allow(exception).to receive(:is_a?).with(Errno).and_return(true) + issues_url = Bundler::FriendlyErrors.issues_url(exception) + expect(issues_url).not_to include("/Users/foo/bar") + expect(issues_url).to eq("https://github.com/bundler/bundler/search?q=#{CGI.escape("Errno EACCES Permission denied @ dir_s_mkdir ")}&type=Issues") + end end end |