1.1.1 ā€¢ Published 4 years ago

con-regex v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

useful npm package to validate/parse Uniform Resource Identifier

šŸ  Homepage

Install

npm install --save con-regex

Usage

Example Usage:

// import/require it using 
const ConRegex = require('con-regex');
// or
import * as ConRegex from 'con-regex'; // theres no default export
// or
import { validateURI, parseURI } from 'con-regex';

// Validation
validateURI('asdkalsdk kasjd sakj dlskj as'); // returns false
validateURI('mysql://user:password@oadpoaw.xyz/dbname') // returns true

// Parsing
parseURI('mysql://user:password@oadpoaw.xyz/dbname?some=value');
// {
//   uri: 'mysql://user:password@oadpoaw.xyz/dbname?some=value',
//   protocol: 'mysql',
//   host: 'oadpoaw.xyz',
//   user: 'user',
//   password: 'password',
//   hostname: 'oadpoaw.xyz',
//   port: undefined,
//   segments: [ 'dbname' ],
//   params: { some: 'value' }
// }

// You can parse multiple uris in an array
parseURI(['mongodb://user:password@c.oadpoaw.xyz/dbname?some=value', 
          'mysql://user:password@oadpoaw.xyz/dbname?some=value']); // [{...}, {...}]

// null values if the uri string has a space or unwanted character
parseURI('asdasdasd asdas'); // null
parseURI(['asda dasd', 'mysql://user:password@oadpoaw.xyz/dbname?some=value']) // [null, {...}]

parseURI('oadpoaw.xyz'); // this works!
parseURI('alsothis'); // also this!

Author

šŸ‘¤ oadpoaw

šŸ¤ Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page.

Show your support

Give a ā­ļø if this project helped you!

šŸ“ License

Copyright Ā© 2020 oadpoaw. This project is MIT licensed.

1.1.1

4 years ago