shopify_app 6.0.1 → 6.0.2

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
  SHA1:
3
- metadata.gz: 29d6e51ca55be46503ae5c1852d423d44f7f5949
4
- data.tar.gz: 050e64759df2bb9aca2cb7d40faab876a3cb0b85
3
+ metadata.gz: 2128cbc693c2918c3f6e8de7f46db48a1eb35970
4
+ data.tar.gz: 7c604d8f79f315f2195fa80c9de2df2f97e124e5
5
5
  SHA512:
6
- metadata.gz: cf160257914859df8d18439adcc242b7963cdc862e24145bd24f119cdce1d154555ca9fa3ff65f1a2556b00466be85db79cc5edb3b6d8458fd96956bd904e910
7
- data.tar.gz: b28d43f8edb5e377969051cc799635c3db7117a0095c7b593d280f974142ecfbf411b298d4f9f53a097bebcebe57b77e0ac43752943dd2fe637d56b15fd92d45
6
+ metadata.gz: 67b2bde7fe1c4aba16f6a4d247b91197fc4d60bb67d1ba3cfabfc0230d9c8a6fd5702982d76601c50b0a7e9bd5cbb5a928b946ccb31f293b0101305816cd57b0
7
+ data.tar.gz: af165ae01b04a02c143c1d73dae6df405d8671ab83ff4635c638763efbe18bcfaa7860f1acec1eab290eec8ef009d193cafe17f8faa4652e64e45d2c5725d7e1
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/lib/shopify_app.rb CHANGED
@@ -15,6 +15,7 @@ require 'shopify_app/shop'
15
15
  require 'shopify_app/controller'
16
16
  require 'shopify_app/sessions_controller'
17
17
  require 'shopify_app/login_protection'
18
+ require 'shopify_app/utils'
18
19
 
19
20
  # session repository
20
21
  require 'shopify_app/shopify_session_repository'
@@ -49,15 +49,7 @@ module ShopifyApp
49
49
 
50
50
  def sanitize_shop_param(params)
51
51
  return unless params[:shop].present?
52
-
53
- name = params[:shop].to_s.strip
54
- name += ".#{ShopifyApp.configuration.myshopify_domain}" if !name.include?("#{ShopifyApp.configuration.myshopify_domain}") && !name.include?(".")
55
- name.sub!(%r|https?://|, '')
56
-
57
- u = URI("http://#{name}")
58
- u.host && u.host.ends_with?(".#{ShopifyApp.configuration.myshopify_domain}") ? u.host : nil
59
- rescue URI::InvalidURIError
60
- nil
52
+ ShopifyApp::Utils.sanitize_shop_domain(params[:shop])
61
53
  end
62
54
 
63
55
  end
@@ -0,0 +1,16 @@
1
+ module ShopifyApp
2
+ module Utils
3
+
4
+ def self.sanitize_shop_domain(shop_domain)
5
+ name = shop_domain.to_s.strip
6
+ name += ".#{ShopifyApp.configuration.myshopify_domain}" if !name.include?("#{ShopifyApp.configuration.myshopify_domain}") && !name.include?(".")
7
+ name.sub!(%r|https?://|, '')
8
+
9
+ u = URI("http://#{name}")
10
+ u.host && u.host.ends_with?(".#{ShopifyApp.configuration.myshopify_domain}") ? u.host : nil
11
+ rescue URI::InvalidURIError
12
+ nil
13
+ end
14
+
15
+ end
16
+ end
@@ -1,3 +1,3 @@
1
1
  module ShopifyApp
2
- VERSION = "6.0.1"
2
+ VERSION = "6.0.2"
3
3
  end
@@ -0,0 +1,30 @@
1
+ require 'test_helper'
2
+
3
+ class UtilsTest < ActiveSupport::TestCase
4
+
5
+ setup do
6
+ ShopifyApp.configuration = nil
7
+ end
8
+
9
+ ['my-shop', 'my-shop.myshopify.com', 'https://my-shop.myshopify.com', 'http://my-shop.myshopify.com'].each do |good_url|
10
+ test "sanitize_shop_domain for (#{good_url})" do
11
+ ShopifyApp.configuration.embedded_app = true
12
+ assert ShopifyApp::Utils.sanitize_shop_domain(good_url)
13
+ end
14
+ end
15
+
16
+ ['my-shop', 'my-shop.myshopify.io', 'https://my-shop.myshopify.io', 'http://my-shop.myshopify.io'].each do |good_url|
17
+ test "sanitize_shop_domain URL (#{good_url}) with custom myshopify_domain" do
18
+ ShopifyApp.configuration.embedded_app = true
19
+ ShopifyApp.configuration.myshopify_domain = 'myshopify.io'
20
+ assert ShopifyApp::Utils.sanitize_shop_domain(good_url)
21
+ end
22
+ end
23
+
24
+ ['myshop.com', 'myshopify.com', 'shopify.com', 'two words', 'store.myshopify.com.evil.com', '/foo/bar'].each do |bad_url|
25
+ test "sanitize_shop_domain for a non-myshopify URL (#{bad_url})" do
26
+ assert_nil ShopifyApp::Utils.sanitize_shop_domain(bad_url)
27
+ end
28
+ end
29
+
30
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.1
4
+ version: 6.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
@@ -30,7 +30,7 @@ cert_chain:
30
30
  fl3hbtVFTqbOlwL9vy1fudXcolIE/ZTcxQ+er07ZFZdKCXayR9PPs64heamfn0fp
31
31
  TConQSX2BnZdhIEYW+cKzEC/bLc=
32
32
  -----END CERTIFICATE-----
33
- date: 2015-04-30 00:00:00.000000000 Z
33
+ date: 2015-05-01 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: rails
@@ -195,6 +195,7 @@ files:
195
195
  - lib/shopify_app/sessions_controller.rb
196
196
  - lib/shopify_app/shop.rb
197
197
  - lib/shopify_app/shopify_session_repository.rb
198
+ - lib/shopify_app/utils.rb
198
199
  - lib/shopify_app/version.rb
199
200
  - shipit.rubygems.yml
200
201
  - shopify_app.gemspec
@@ -223,6 +224,7 @@ files:
223
224
  - test/shopify_app/in_memory_session_store_test.rb
224
225
  - test/shopify_app/login_protection_test.rb
225
226
  - test/shopify_app/shopify_session_repository_test.rb
227
+ - test/shopify_app/utils_test.rb
226
228
  - test/support/generator_test_helpers.rb
227
229
  - test/test_helper.rb
228
230
  homepage:
metadata.gz.sig CHANGED
Binary file