Method: TDiary::RefererManager#add_referer

Defined in:
lib/tdiary/referer_manager.rb

#add_referer(ref, count = 1) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/tdiary/referer_manager.rb', line 18

def add_referer( ref, count = 1 )
	newer_referer
	ref = ref.sub( /#.*$/, '' ).sub( /\?\d{8}$/, '' )
	if /^([^:]+:\/\/)([^\/]+)/ =~ ref
		ref = $1 + $2.downcase + $'
	end
	begin
		uref = CGI::unescape( ref )
	rescue ::Encoding::CompatibilityError
		return
	end
	if pair = @referers[uref] then
		pair = [pair, ref] if pair.class != Array # for compatibility
		@referers[uref] = [pair[0] + count, pair[1]]
	else
		@referers[uref] = [count, ref]
	end
end