Skip to content

Commit

Permalink
fix: allow port number in callback URLs of API_ONLY apps
Browse files Browse the repository at this point in the history
  • Loading branch information
bflorian committed Sep 3, 2024
1 parent 5776de6 commit 84de99e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/bright-books-fail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@smartthings/cli-lib": patch
---

Allow port number in callback URLs of API_ONLY apps.
2 changes: 2 additions & 0 deletions packages/lib/src/__tests__/validate-util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ describe('localhostOrHTTPSValidate', () => {
'https://www.adafruit.com/category/168',
'http://localhost/path/to/fun',
'http://127.0.0.1',
'http://localhost:3000',
'http://127.0.0.1:3000/callback',
])('accepts "%s" when https is required', (input) => {
expect(localhostOrHTTPSValidate(input)).toBe(true)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/src/validate-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const urlValidateFn = (options?: URLValidateFnOptions): ValidateFunction => {
if (options?.httpsRequired) {
if (options.allowLocalhostHTTP) {
return url.protocol === 'https:' ||
url.protocol === 'http:' && allowedHTTPHosts.includes(url.host) ||
url.protocol === 'http:' && allowedHTTPHosts.includes(url.hostname) ||
'https is required except for localhost'
}
return url.protocol === 'https:' || 'https protocol is required'
Expand Down

0 comments on commit 84de99e

Please sign in to comment.