workarea-core 3.4.41 → 3.4.42
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fb1a7c0e5cf9108b58d636eca7349f0ec61c1c24b91e3356d6978a70048fb745
|
4
|
+
data.tar.gz: 46609e92ace1945db58648ce33306fb2000532d9b1867bbf1a8530484e2a2ba0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4320bf6ca0537e6aa5e5ca6c3c5afd68cd269579fc38f8acff6d669064c8d8aaf37b2afadc160edf8c55fb4857834cb9d9a38a1a6e9fdb9e2f36bae62781d286
|
7
|
+
data.tar.gz: 353ee66c41b45fe5695a19c444fb8f21e4c35140cdfa804f03b8da50bb6cd2e6e70d05e1ee06b61cc4577c666d68dca09f4e58915a04b1974f7b916eacc531b0
|
data/lib/workarea/core.rb
CHANGED
@@ -140,6 +140,7 @@ require 'workarea/ext/mongoid/find_ordered'
|
|
140
140
|
require 'workarea/ext/sprockets/ruby_processor'
|
141
141
|
require 'workarea/ext/jbuilder/jbuilder_append_partials'
|
142
142
|
require 'workarea/ext/jbuilder/jbuilder_cache'
|
143
|
+
require 'workarea/ext/referer_parser/parser.decorator'
|
143
144
|
|
144
145
|
if Rails.env.development?
|
145
146
|
require 'workarea/ext/freedom_patches/routes_reloader'
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module RefererParser
|
2
|
+
# This code is actually in `master` branch of
|
3
|
+
# https://github.com/snowplow-referer-parser/ruby-referer-parser but
|
4
|
+
# has not yet been released. It's used to allow through android-app://
|
5
|
+
# URLs.
|
6
|
+
decorate Parser do
|
7
|
+
# Given a string or URI, return a hash of data
|
8
|
+
def parse(obj)
|
9
|
+
url = obj.is_a?(URI) ? obj : URI.parse(obj.to_s)
|
10
|
+
|
11
|
+
unless ['android-app', 'http', 'https'].include?(url.scheme)
|
12
|
+
raise InvalidUriError, "Only Android-App, HTTP, and HTTPS schemes are supported -- #{url.scheme}"
|
13
|
+
end
|
14
|
+
|
15
|
+
data = { known: false, uri: url.to_s }
|
16
|
+
|
17
|
+
domain, name_key = domain_and_name_key_for(url)
|
18
|
+
if domain && name_key
|
19
|
+
referer_data = @name_hash[name_key]
|
20
|
+
data[:known] = true
|
21
|
+
data[:source] = referer_data[:source]
|
22
|
+
data[:medium] = referer_data[:medium]
|
23
|
+
data[:domain] = domain
|
24
|
+
|
25
|
+
# Parse parameters if the referer uses them
|
26
|
+
if url.query && referer_data[:parameters]
|
27
|
+
query_params = CGI.parse(url.query)
|
28
|
+
referer_data[:parameters].each do |param|
|
29
|
+
# If there is a matching parameter, get the first non-blank value
|
30
|
+
unless (values = query_params[param]).empty?
|
31
|
+
data[:term] = values.reject { |v| v.strip == '' }.first
|
32
|
+
break if data[:term]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
data
|
39
|
+
rescue URI::InvalidURIError
|
40
|
+
raise InvalidUriError.new("Unable to parse URI, not a URI? -- #{obj.inspect}", $ERROR_INFO)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/workarea/version.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module RefererParser
|
4
|
+
class ParserTest < Workarea::TestCase
|
5
|
+
def test_parse_android_app_referrers
|
6
|
+
referrers = [
|
7
|
+
'android-app://com.linkedin.android',
|
8
|
+
'android-app://org.telegram.plus',
|
9
|
+
'android-app://com.twitter.android'
|
10
|
+
]
|
11
|
+
|
12
|
+
referrers.each do |uri|
|
13
|
+
referrer = Parser.new.parse(uri)
|
14
|
+
|
15
|
+
refute(referrer[:known])
|
16
|
+
assert_equal(uri, referrer[:uri])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workarea-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.4.
|
4
|
+
version: 3.4.42
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Crouse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -1873,6 +1873,7 @@ files:
|
|
1873
1873
|
- lib/workarea/ext/mongoid/list_field.rb
|
1874
1874
|
- lib/workarea/ext/mongoid/moped_bson.rb
|
1875
1875
|
- lib/workarea/ext/mongoid/timestamps_timeless.rb
|
1876
|
+
- lib/workarea/ext/referer_parser/parser.decorator
|
1876
1877
|
- lib/workarea/ext/sprockets/ruby_processor.rb
|
1877
1878
|
- lib/workarea/ext/sprockets/task.rb
|
1878
1879
|
- lib/workarea/geolocation.rb
|
@@ -2017,6 +2018,7 @@ files:
|
|
2017
2018
|
- test/lib/workarea/ext/mongoid/except_test.rb
|
2018
2019
|
- test/lib/workarea/ext/mongoid/find_ordered_test.rb
|
2019
2020
|
- test/lib/workarea/ext/mongoid/list_field_test.rb
|
2021
|
+
- test/lib/workarea/ext/referer_parser/parser_test.rb
|
2020
2022
|
- test/lib/workarea/geolocation_test.rb
|
2021
2023
|
- test/lib/workarea/lint/inconsistent_details_test.rb
|
2022
2024
|
- test/lib/workarea/lint/products_missing_images_test.rb
|