# url-parse-as-address

> Parse a url assuming `http` if no protocol or `//` is provided.

Latest version **1.0.0** (published 2015-01-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install url-parse-as-address
pnpm add url-parse-as-address
yarn add url-parse-as-address
bun add url-parse-as-address
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-01-20 |
| First published | 2015-01-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 17 |
| Author | Isaac Z. Schlueter |
| Maintainers | isaacs |
| Keywords | url, parse, addressbar, http |

## Links

- npm: https://www.npmjs.com/package/url-parse-as-address
- Repository: https://github.com/isaacs/url-parse-as-address
- Issues: https://github.com/isaacs/url-parse-as-address/issues
- npm.io page: https://npm.io/package/url-parse-as-address

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2015-01-20

## README

# url-parse-as-address

Parse a url assuming `http` if no protocol or `//` is provided.

Useful for parsing things like `foo.com` and not interpreting it as a
path.

## USAGE

```javascript
var parse = require('url-parse-as-address')
var assert = require('assert')

assert.deepEqual(parse('foo.com:1234/x?y=z#a=b'),
  { protocol: 'http:',
    slashes: true,
    auth: null,
    host: 'foo.com:1234',
    port: '1234',
    hostname: 'foo.com',
    hash: '#a=b',
    search: '?y=z',
    query: 'y=z',
    pathname: '/x',
    path: '/x?y=z',
    href: 'http://foo.com:1234/x?y=z#a=b' })

assert.deepEqual(parse('foo.com:1234/x?y=z#a=b', true),
  { protocol: 'http:',
    slashes: true,
    auth: null,
    host: 'foo.com:1234',
    port: '1234',
    hostname: 'foo.com',
    hash: '#a=b',
    search: '?y=z',
    query: { y: 'z' },
    pathname: '/x',
    path: '/x?y=z',
    href: 'http://foo.com:1234/x?y=z#a=b' })

// etc
```

By default this lib assumes `http:` is the protocol if none is
provided, because that's what web browsers do.

## API

* `parse(url, parseQueryString)` Parse a string to object.

* `parse.parse(..)` Same function, for symmetry to `url` builtin

* `parse.format(url)` Like `url.format()`

## SEE ALSO

* https://iojs.org/api/url.html
* https://nodejs.org/api/url.html

---
_Source: https://npm.io/package/url-parse-as-address · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
