Sha256: c186925ec0fa6097aaca6a0d699a5af9dea59b34e95dcdbde7d8fb23c38d857d

Contents?: true

Size: 564 Bytes

Versions: 2

Compression:

Stored size: 564 Bytes

Contents

require 'murlsh'

module Murlsh

  # Convert urls specifically for use on mobile devices into their non-mobile
  # equivalents.
  class AddPre40ConvertMobile < Plugin

    @hook = 'add_pre'

    TwitterRe = %r{^(http://)mobile\.(twitter\.com/.*)$}i
    WikipediaRe = %r{^(http://[a-z]+\.)m\.(wikipedia\.org/.*)$}i

    def self.run(url, config)
      url.url = case
        when match = TwitterRe.match(url.url); "#{match[1]}#{match[2]}"
        when match = WikipediaRe.match(url.url); "#{match[1]}#{match[2]}"
        else; url.url
      end
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
murlsh-1.2.0 plugins/add_pre_40_convert_mobile.rb
murlsh-1.1.0 plugins/add_pre_40_convert_mobile.rb