Use String#include? instead of end_with? to avoid message duplication

Previously, did_you_mean used `msg.end_with?(suggestion)` to check if
its suggestion is already added.

I'm now creating a gem that also modifies Exception's message. This
breaks did_you_mean's duplication check.
This change makes the check use String#include? instead of end_with?.

https://github.com/ruby/did_you_mean/commit/b35e030549
This commit is contained in:
Yusuke Endoh 2021-06-18 17:45:10 +09:00
parent 612b6fcd37
commit 809f120374
1 changed files with 1 additions and 1 deletions

View File

@ -15,7 +15,7 @@ module DidYouMean
msg = super.dup
suggestion = DidYouMean.formatter.message_for(corrections)
msg << suggestion if !msg.end_with?(suggestion)
msg << suggestion if !msg.include?(suggestion)
msg
rescue
super