Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

requires-port

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

requires-port

Check if a protocol requires a certain port number to be added to an URL.

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.9M
decreased by-62.21%
Maintainers
2
Weekly downloads
 
Created

What is requires-port?

The `requires-port` package is a simple utility used to determine if a default port is required for a given protocol. It's particularly useful when working with URLs or networking in Node.js applications, where you might need to append a port to a hostname based on the protocol being used. This package helps in making decisions about whether to include the port in a URL string.

What are requires-port's main functionalities?

Checking if a port is required for a protocol

This feature allows you to check if a specific port is typically required for a given protocol. For standard protocols like HTTP (80) and HTTPS (443), it returns `false` indicating that the port does not need to be explicitly mentioned in a URL since it's the default. For non-standard ports or protocols, it returns `true`, suggesting that the port should be specified. The code sample demonstrates how to use `requires-port` to check for common and custom protocols.

"use strict";\nconst requiresPort = require('requires-port');\n\n// Example for HTTP\nconsole.log(requiresPort(80, 'http')); // false\n\n// Example for HTTPS\nconsole.log(requiresPort(443, 'https')); // false\n\n// Example for a custom protocol\nconsole.log(requiresPort(8080, 'my-protocol')); // true"

Other packages similar to requires-port

Keywords

FAQs

Package last updated on 26 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc