Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

search_engine_referer

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

search_engine_referer

  • 0.1.4
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

#SearchEngineReferer Get meta information from search engine`s referer for

  • google.com
  • bing.com
  • yandex.ru
  • go.mail.ru
  • nova.rambler.ru

##Instalation Add the folowing line to Gemfile and then run bundle command.

gem 'search_engine_referer'

##Usage In your code use:

referer = SearchEngineReferer.parse('http://google.com?q=ruby&start=20')
referef.search_engine # => :google
referer.page # => 3
referer.query # => 'ruby'

non_search_enfine_referer = SearchEngineReferer.parse('http://example.com?q=ruby')
non_search_enfine_referef # => nil

##Middleware Tiny middleware provided. It adds search_engine_referer key to env with found referer. Examples:

  • Uses HTTP_REFERER from env

    use SearchEngineReferer::Middleware
    
  • Uses CUSTOM_ENV_KEY for referer lookup

    use SearchEngineReferer::Middleware, 'CUSTOM_ENV_KEY'
    
  • Uses provided proc for referer lookup

    use SearchEngineReferer::Middleware do |env|
      env['action_pack.cookies']['referer']
    end
    

##Controller Helpers Its add helpers for controllers and views: search_engine_referer and search_engine_query. search_engine_referer_source method for referer source manipulations. By default it returns request.referer. It can be overwritten in controller, for example:

def search_engine_referer_source
  cookies[:search_engine_referer] || super
end

Note that helpers will use env['search_engine_referer'] if it provided by middleware

##Development Fully tested pull requests are welcome.

FAQs

Package last updated on 30 Dec 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc