1.1.1 ā¢ Published 4 years ago
con-regex v1.1.1
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
- Website: https://oadpoaw.xyz/
- Github: @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
1.1.1
4 years ago