Skip to content
I'll give you the right URL, but don't call me Shirley!
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows
.eslintrc.js
.gitignore
.nvmrc
.prettierignore
.prettierrc.js
README.md
index.js
package-lock.json
package.json
test.js

README.md

Shurley

I'll give you the right URL, but don't call me Shirley!

Parses URLs from user input (with potential typos in protocols, bad copy+paste, etc.) and returns a proper URL.

It has no dependencies, and it's meant to be this simple.

Some things to note:

  1. It doesn't check if the URL exists, you can do that in many different ways.

  2. It assumes only http and https protocols for URLs.

  3. If there's a "mistake" in the URL protocol, it defaults to https.

Usage

It only has a single method: parse(url: string) which returns the same string, parsed.

npm install --save shurley
const shurley = require('shurley');

const parsedUrl = shurley.parse('/example.com');

console.log(parsedUrl); // Outputs 'https://example.com'

Development

npm install  # installs dependencies
npm test  # runs mocha
npm run lint  # runs eslint
npm run pretty  # runs prettier

Publishing

Update the version, run tests, then just run npm publish.

You can’t perform that action at this time.