Skip to content

Commit bed77e4

Browse files
Merge pull request #1004 from hoppergee/http_webhook_registration_fix
Support full URL and schemeless URL when register HTTP webhooks as usual
2 parents e3ec2ad + 2bd5f24 commit bed77e4

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Note: For changes to the API, see https://shopify.dev/changelog?filter=api
99
## Version 11.1.0
1010

1111
- [#1002](https://github.com/Shopify/shopify-api-ruby/pull/1002) Add new method to construct the host app URL for an embedded app, allowing for safer redirect to app inside appropriate shop admin
12+
- [#1004](https://github.com/Shopify/shopify-api-ruby/pull/1004) Support full URL and scheme-less URL when registering HTTP webhooks
1213

1314
## Version 11.0.1
1415

lib/shopify_api/webhooks/registrations/http.rb

+7-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ class Http < Registration
99

1010
sig { override.returns(String) }
1111
def callback_address
12-
"https://#{Context.host_name}/#{@path}"
12+
if @path.match?(%r{^https://})
13+
@path
14+
elsif @path.match?(/^#{Context.host_name}/)
15+
"https://#{@path}"
16+
else
17+
"https://#{Context.host_name}/#{@path}"
18+
end
1319
end
1420

1521
sig { override.returns(T::Hash[Symbol, String]) }

test/webhooks/registry_test.rb

+8
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ def test_http_registration_add_and_update
8282
do_registration_test(:http, "test-webhooks")
8383
end
8484

85+
def test_http_registration_add_and_update_with_full_url
86+
do_registration_test(:http, "https://app-address.com/test-webhooks")
87+
end
88+
89+
def test_http_registration_add_and_update_with_schemeless_url
90+
do_registration_test(:http, "app-address.com/test-webhooks")
91+
end
92+
8593
def test_http_registration_with_fields_add_and_update
8694
do_registration_test(:http, "test-webhooks", fields: "field1, field2")
8795
end

0 commit comments

Comments
 (0)