lib/cms_scanner/finders/finder.rb in cms_scanner-0.6.2 vs lib/cms_scanner/finders/finder.rb in cms_scanner-0.7.0
- old
+ new
@@ -18,11 +18,15 @@
@target = target
end
# @return [ String ] The titleized name of the finder
def titleize
- self.class.to_s.demodulize.underscore.titleize
+ # Put a _ char before any digits except those at the end, which will be replaced by a space
+ # Otherwise, class such as Error404Page are returned as Error404 Page instead of Error 404 page
+ # The keep_id_suffix is to concevert classes such as CssId to Css Id instead of Css
+
+ @titleize ||= self.class.to_s.demodulize.gsub(/(\d+)[a-z]+/i, '_\0').titleize(keep_id_suffix: true)
end
# @param [ Hash ] _opts
def passive(_opts = {}); end
@@ -48,18 +52,20 @@
# @return [ Typhoeus::Hydra ]
def hydra
@hydra ||= browser.hydra
end
- # @param [ String, Symbol ] klass
+ # @param [String, Class ] klass
# @return [ String ]
- def found_by(klass = self)
+ def found_by(klass = self.class)
caller_locations.each do |call|
label = call.label
next unless %w[aggressive passive].include? label
- return "#{klass.titleize} (#{label.capitalize} Detection)"
+ title = klass.to_s.demodulize.gsub(/(\d+)[a-z]+/i, '_\0').titleize(keep_id_suffix: true)
+
+ return "#{title} (#{label.capitalize} Detection)"
end
nil
end
end
end