Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/BrunoBernardino/shurley
I'll give you the right URL, but don't call me Shirley!
https://github.com/BrunoBernardino/shurley
deno javascript npm package typescript url-parser
Last synced: 2 months ago
JSON representation
I'll give you the right URL, but don't call me Shirley!
- Host: GitHub
- URL: https://github.com/BrunoBernardino/shurley
- Owner: BrunoBernardino
- Created: 2020-01-05T19:07:15.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-02-24T20:42:26.000Z (4 months ago)
- Last Synced: 2024-03-29T09:04:55.988Z (3 months ago)
- Topics: deno, javascript, npm, package, typescript, url-parser
- Language: TypeScript
- Homepage: https://deno.land/x/shurley
- Size: 289 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
Lists
- awesome-micro-npm-packages - shurley - Parses URLs from user input (with potential typos in protocols, bad copy+paste, etc.) and returns a proper URL. (Modules / Other)
README
# Shurley
[![](https://github.com/BrunoBernardino/shurley/workflows/Run%20Tests/badge.svg)](https://github.com/BrunoBernardino/shurley/actions?workflow=Run+Tests) [![deno](https://shield.deno.dev/x/shurley)](https://deno.land/x/shurley) [![npm](https://img.shields.io/npm/v/shurley.svg)](https://www.npmjs.com/package/shurley)
> I'll give you the right URL, but [don't call me Shirley!](https://www.youtube.com/watch?v=ixljWVyPby0)
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.
### Deno
```ts
import shurley from 'https://deno.land/x/[email protected]/mod.ts';const parsedUrl = shurley.parse('example.com');
console.log(parsedUrl); // Outputs 'https://example.com'
```### Node/NPM
```bash
npm install --save-exact shurley
``````js
const shurley = require('shurley'); // or import shurley from 'shurley';const parsedUrl = shurley.parse('example.com');
console.log(parsedUrl); // Outputs 'https://example.com'
```## Development
Requires `deno`.
```bash
make format
make test
```## Publishing
After committing and pushing, just run `make publish VERSION=x.y.z`.