Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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