Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/unjs/requrl
Grab full URL from request.
https://github.com/unjs/requrl
http incomingmessage node req url
Last synced: 4 months ago
JSON representation
Grab full URL from request.
- Host: GitHub
- URL: https://github.com/unjs/requrl
- Owner: unjs
- Created: 2019-11-21T16:01:22.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-04-29T10:14:48.000Z (9 months ago)
- Last Synced: 2024-09-15T05:50:50.633Z (4 months ago)
- Topics: http, incomingmessage, node, req, url
- Language: TypeScript
- Homepage:
- Size: 332 KB
- Stars: 38
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# requrl
[![npm](https://flat.badgen.net/npm/v/requrl)](https://www.npmjs.com/package/requrl)
[![dt](https://flat.badgen.net/npm/dt/requrl)](https://www.npmjs.com/package/requrl)
[![bundlephobia](https://flat.badgen.net/bundlephobia/minzip/requrl)](https://bundlephobia.com/result?p=requrl)Grab full URL from [request](https://nodejs.org/api/http.html#http_class_http_incomingmessage).
## Features
- Universal (browser and node.js) support
- Detect HTTPS requests using [is-https](https://github.com/nuxt-contrib/is-https)
- Support `x-forwarded-proto` and `x-forwarded-host`
- Always encode URI
- Super Small## Usage
```js
import getURL from 'requrl'
// OR
const getURL = require('requrl')
```Function signuture is:
```ts
function getURL(req?: IncomingMessage, includePath?: boolean): string
```Example:
```js
const url = getURL(req)
// http://localhost:3000
// https://www.foo.com
```## License
MIT