class MediaWiki::Utils
Util class similar to MediaWiki's non-API util methods. This is not required automatically by requiring 'mediawiki-butt' or 'mediawiki/butt'; you must require it explicitly.
Public Class Methods
encode_url(str)
click to toggle source
Encodes the URL like mw.util.rawurlencode JS. @todo Require StringUtility and use its safely_gsub method. @param str [String] The string to replace (typically a page title). @return [String] The encoded string.
# File lib/mediawiki/utils.rb, line 9 def self.encode_url(str) str.gsub!(/!/, '%21') || str str.gsub!(/'/, '%27') || str str.gsub!(/\(/, '%28') || str str.gsub!(/\)/, '%29') || str str.gsub!(/\*/, '%2A') || str str.gsub!(/~/, '%7E') || str str end