Skip to content

Commit

Permalink
feat: port support string type
Browse files Browse the repository at this point in the history
  • Loading branch information
sapenlei committed Nov 12, 2024
1 parent 40724aa commit 23af537
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/internal/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,16 @@ export function probeContentType(path: string) {
* is input port valid.
*/
export function isValidPort(port: unknown): port is number {
// verify if port is a number.
if (!isNumber(port)) {
// Convert string port to number if needed
const portNum = typeof port === 'string' ? parseInt(port, 10) : port

// verify if port is a valid number
if (!isNumber(portNum) || isNaN(portNum)) {
return false
}

// port `0` is valid and special case
return 0 <= port && port <= 65535
return 0 <= portNum && portNum <= 65535
}

export function isValidBucketName(bucket: unknown) {
Expand Down

0 comments on commit 23af537

Please sign in to comment.