Skip to content

Commit

Permalink
Extend aws region validation (#430)
Browse files Browse the repository at this point in the history
* allow extra aws region

* add unit test for gov cloud

* matches any pattern between iot and amazonaws

* update to avoid empty string or . in region sub-str
  • Loading branch information
xiazhvera authored Jun 4, 2024
1 parent 42c2d9d commit a8c734f
Show file tree
Hide file tree
Showing 2 changed files with 186 additions and 153 deletions.
3 changes: 2 additions & 1 deletion device/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,8 @@ function DeviceClient(options) {
}

if (!isUndefined(options.host) && isUndefined(options.region)) {
var pattern = /[a-zA-Z0-9]+\.iot\.([a-z]+-[a-z]+-[0-9]+)\.amazonaws\..+/;
// extract anything in between "iot" and "amazonaws" as region
var pattern = /[a-zA-Z0-9]+\.iot\.([^\.]+)\.amazonaws\..+/;
var region = pattern.exec(options.host);
if (region === null) {
console.log('Host endpoint is not valid');
Expand Down
Loading

0 comments on commit a8c734f

Please sign in to comment.