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

valid-url

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

valid-url

URI validation functions

  • 1.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.4M
decreased by-3.39%
Maintainers
2
Weekly downloads
 
Created

What is valid-url?

The valid-url npm package provides utilities for URL validation and parsing. It allows developers to check if a given string is a valid URL and to parse URLs into their components.

What are valid-url's main functionalities?

URL Validation

This feature allows you to check if a string is a valid URL. The `isUri` method returns the URL if it's valid, otherwise undefined. It's useful for validating URLs before attempting to make HTTP requests or storing them in a database.

"use strict";\nconst validUrl = require('valid-url');\n\nif (validUrl.isUri('http://www.google.com')){\n    console.log('Looks like an URI');\n} else {\n    console.log('Not a URI');\n}"

URL Parsing

While the primary focus of valid-url is validation, the returned valid URI string from `isUri` can be further parsed using other libraries or custom code to extract components like protocol, host, path, and query parameters. This example demonstrates basic usage for validation, hinting at further parsing possibilities.

"use strict";\nconst validUrl = require('valid-url');\n\nlet uri = validUrl.isUri('http://www.example.com/path?name=query');\nif (uri){\n    console.log('URI is', uri);\n    // Additional parsing logic here\n} else {\n    console.log('Not a URI');\n}"

Other packages similar to valid-url

Keywords

FAQs

Package last updated on 31 Jul 2013

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