summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Heinen <theinen@tecracer.de>2022-07-19 17:37:34 +0200
committerPrajaktaPurohit <PrajaktaPurohit@users.noreply.github.com>2022-10-25 10:28:10 -0700
commit17104003c2e05f1a04e2c030b8e14e1f9157e8bd (patch)
tree22dc4bd91874c503868aa9e17976431b7673ffd9
parent5fc5ac73d8a5eec7381da91efd38b431bda6c1bd (diff)
downloadchef-17104003c2e05f1a04e2c030b8e14e1f9157e8bd.tar.gz
Fix error on wrong URLs in REST DSL
Signed-off-by: Thomas Heinen <theinen@tecracer.de>
-rw-r--r--lib/chef/dsl/rest_resource.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/chef/dsl/rest_resource.rb b/lib/chef/dsl/rest_resource.rb
index 96eba24eac..2c435930e9 100644
--- a/lib/chef/dsl/rest_resource.rb
+++ b/lib/chef/dsl/rest_resource.rb
@@ -31,13 +31,20 @@ class Chef
# URL to collection
def rest_api_collection(rest_api_collection = NOT_PASSED)
- @rest_api_collection = rest_api_collection if rest_api_collection != NOT_PASSED
+ if rest_api_collection != NOT_PASSED
+ raise ArgumentError, "You must pass an absolute path to rest_api_collection" unless rest_api_collection.start_with? "/"
+
+ @rest_api_collection = rest_api_collection
+ end
+
@rest_api_collection
end
# RFC6570-Templated URL to document
def rest_api_document(rest_api_document = NOT_PASSED, first_element_only: false)
if rest_api_document != NOT_PASSED
+ raise ArgumentError, "You must pass an absolute path to rest_api_document" unless rest_api_document.start_with? "/"
+
@rest_api_document = rest_api_document
@rest_api_document_first_element_only = first_element_only
end