Sha256: b09a6739009b9f6d1b9f61c6d01e615019b83bfc5ac6729b85b6f2af842e531c
Contents?: true
Size: 481 Bytes
Versions: 3
Compression:
Stored size: 481 Bytes
Contents
require "addressable/uri" class TaiwaneseNewsParser::UrlCleaner # white_list: Array of string, denoting url query # parameters that cleaner should keep def initialize(white_list = nil) @white_list = Array(white_list) @white_list.map!(&:to_s) end def clean(url) @url = Addressable::URI.parse(url) params = @url.query_values if params params.keep_if{|k,v| @white_list.include?(k) } end @url.query_values = params @url.to_s end end
Version data entries
3 entries across 3 versions & 1 rubygems