Skip to content

Commit a8c734f

Browse files
authored
Extend aws region validation (#430)
* 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
1 parent 42c2d9d commit a8c734f

File tree

2 files changed

+186
-153
lines changed

2 files changed

+186
-153
lines changed

device/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,8 @@ function DeviceClient(options) {
512512
}
513513

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

0 commit comments

Comments
 (0)