Comparing version 0.3.1 to 0.4.0
@@ -5,2 +5,13 @@ # Changelog | ||
## [0.4.0](https://github.com/nuxt-contrib/ufo/compare/v0.3.1...v0.4.0) (2020-12-16) | ||
### ⚠ BREAKING CHANGES | ||
* lightweight joinURL + resolveURL | ||
### Features | ||
* lightweight joinURL + resolveURL ([9a34622](https://github.com/nuxt-contrib/ufo/commit/9a3462285bd84a5fec68bac1439828f21794e418)) | ||
### [0.3.1](https://github.com/nuxt-contrib/ufo/compare/v0.3.0...v0.3.1) (2020-12-16) | ||
@@ -7,0 +18,0 @@ |
@@ -53,2 +53,3 @@ declare type ParamsObject = Record<string, string | string[]>; | ||
declare function joinURL(base: string, ...input: string[]): string; | ||
declare function resolveURL(base: string, ...input: string[]): string; | ||
@@ -112,2 +113,2 @@ /** | ||
export { ParamsObject, ParsedURL, UFO, cleanDoubleSlashes, createURL, decode, encode, encodeHash, encodeHost, encodeParam, encodePath, encodeQueryKey, encodeQueryValue, encodeSearchParam, getParams, hasProtocol, joinURL, normalizeURL, parseParams, parsePath, parseURL, parsedParamsToObject, withLeadingSlash, withParams, withTrailingSlash, withoutLeadingSlash, withoutTrailingSlash }; | ||
export { ParamsObject, ParsedURL, UFO, cleanDoubleSlashes, createURL, decode, encode, encodeHash, encodeHost, encodeParam, encodePath, encodeQueryKey, encodeQueryValue, encodeSearchParam, getParams, hasProtocol, joinURL, normalizeURL, parseParams, parsePath, parseURL, parsedParamsToObject, resolveURL, withLeadingSlash, withParams, withTrailingSlash, withoutLeadingSlash, withoutTrailingSlash }; |
@@ -305,2 +305,9 @@ 'use strict'; | ||
function joinURL(base, ...input) { | ||
let url = base || ""; | ||
for (const i of input) { | ||
url = withTrailingSlash(url) + withoutLeadingSlash(i); | ||
} | ||
return url; | ||
} | ||
function resolveURL(base, ...input) { | ||
const url = createURL(base); | ||
@@ -333,2 +340,3 @@ for (const i of input) { | ||
exports.parsedParamsToObject = parsedParamsToObject; | ||
exports.resolveURL = resolveURL; | ||
exports.withLeadingSlash = withLeadingSlash; | ||
@@ -335,0 +343,0 @@ exports.withParams = withParams; |
{ | ||
"name": "@nuxt/ufo", | ||
"version": "0.3.1", | ||
"version": "0.4.0", | ||
"description": "URL utils for humans", | ||
@@ -5,0 +5,0 @@ "repository": "nuxt-contrib/ufo", |
@@ -10,2 +10,11 @@ [![npm version][npm-version-src]][npm-version-href] | ||
UFO exports URL utilities based on a URL-like interface with some improvements: | ||
- Supporting schemeless and hostless URLs | ||
- Supporting relative URLs | ||
- Preserving trailing-slash status | ||
- Decoded and mutable classs properties | ||
- Consistent URL parser independent of environment | ||
- Consistent encoding independent of environment | ||
## Install | ||
@@ -55,3 +64,7 @@ | ||
joinURL('a', '/b', '/c') | ||
``` | ||
### `resolveURL` | ||
```ts | ||
// Result: http://foo.com/foo/bar/baz?test=123#token | ||
@@ -106,4 +119,6 @@ joinURL('http://foo.com/foo?test=123#token', 'bar', 'baz') | ||
MIT. Made with 💖 | ||
[MIT](./LICENSE) | ||
Special thanks to Eduardo San Martin Morote ([posva](https://github.com/posva)) for [encoding utlities](https://github.com/vuejs/vue-router-next/blob/v4.0.1/src/encoding.ts) | ||
<!-- Badges --> | ||
@@ -110,0 +125,0 @@ [npm-version-src]: https://img.shields.io/npm/v/@nuxt/ufo?style=flat-square |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33763
757
136