Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: port support string type #1356

Merged
merged 1 commit into from
Nov 16, 2024
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
Loading