Class: IdsPlease::Parsers::Facebook

Inherits:
Base
  • Object
show all
Defined in:
lib/ids_please/parsers/facebook.rb

Constant Summary collapse

MASK =
/fb\.me|fb\.com|facebook/i

Class Method Summary collapse

Methods inherited from Base

interact, to_sym, valid_id_regex

Class Method Details



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ids_please/parsers/facebook.rb', line 8

def parse_link(link)
  query = CGI.parse(link.query) if link.query && !link.query.empty?

  if query && !query['id'].empty?
    query['id'].first
  elsif link.path =~ /\/pages\//
    link.path.split('/').last
  else
    link.path.split('/')[1]
  end
end