Skip to content

Commit 6b00230

Browse files
committed
chore: format readme with prettier
1 parent 3b66d62 commit 6b00230

File tree

1 file changed

+40
-39
lines changed

1 file changed

+40
-39
lines changed

README.md

+40-39
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ Import:
2121

2222
```js
2323
// CommonJS
24-
const { normalizeURL, joinURL } = require('ufo')
24+
const { normalizeURL, joinURL } = require("ufo");
2525

2626
// ESM
27-
import { normalizeURL, joinURL } from 'ufo'
27+
import { normalizeURL, joinURL } from "ufo";
2828

2929
// Deno
30-
import { parseURL } from 'https://unpkg.com/ufo/dist/index.mjs'
30+
import { parseURL } from "https://unpkg.com/ufo/dist/index.mjs";
3131
```
3232

3333
**Notice:** You may need to transpile package and add URL polyfill for legacy environments
@@ -41,72 +41,72 @@ import { parseURL } from 'https://unpkg.com/ufo/dist/index.mjs'
4141
- Preserves protocol/host if provided
4242

4343
```ts
44-
normalizeURL('test?query=123 123#hash, test')
44+
normalizeURL("test?query=123 123#hash, test");
4545
// test?query=123%20123#hash,%20test
4646

47-
normalizeURL('http://localhost:3000')
47+
normalizeURL("http://localhost:3000");
4848
// http://localhost:3000/
4949
```
5050

5151
### `joinURL`
5252

5353
```ts
54-
joinURL('a', '/b', '/c')
54+
joinURL("a", "/b", "/c");
5555
// a/b/c
5656
```
5757

5858
### `resolveURL`
5959

6060
```ts
61-
resolveURL('http://foo.com/foo?test=123#token', 'bar', 'baz')
61+
resolveURL("http://foo.com/foo?test=123#token", "bar", "baz");
6262
// http://foo.com/foo/bar/baz?test=123#token
6363
```
6464

6565
### `parseURL`
6666

6767
```ts
68-
parseURL('http://foo.com/foo?test=123#token')
68+
parseURL("http://foo.com/foo?test=123#token");
6969
// { protocol: 'http:', auth: '', host: 'foo.com', pathname: '/foo', search: '?test=123', hash: '#token' }
7070

71-
parseURL('foo.com/foo?test=123#token')
71+
parseURL("foo.com/foo?test=123#token");
7272
// { pathname: 'foo.com/foo', search: '?test=123', hash: '#token' }
7373

74-
parseURL('foo.com/foo?test=123#token', 'https://')
74+
parseURL("foo.com/foo?test=123#token", "https://");
7575
// { protocol: 'https:', auth: '', host: 'foo.com', pathname: '/foo', search: '?test=123', hash: '#token' }
7676
```
7777

7878
### `stringifyParsedURL`
7979

8080
```ts
81-
const obj = parseURL('http://foo.com/foo?test=123#token')
82-
obj.host = 'bar.com'
81+
const obj = parseURL("http://foo.com/foo?test=123#token");
82+
obj.host = "bar.com";
8383

84-
stringifyParsedURL(obj)
84+
stringifyParsedURL(obj);
8585
// http://bar.com/foo?test=123#token
8686
```
8787

8888
### `withQuery`
8989

9090
```ts
91-
withQuery('/foo?page=a', { token: 'secret' })
91+
withQuery("/foo?page=a", { token: "secret" });
9292
// /foo?page=a&token=secret
9393
```
9494

9595
### `getQuery`
9696

9797
```ts
98-
getQuery('http://foo.com/foo?test=123&unicode=%E5%A5%BD')
98+
getQuery("http://foo.com/foo?test=123&unicode=%E5%A5%BD");
9999
// { test: '123', unicode: '好' }
100100
```
101101

102102
### `parseFilename`
103103

104104
```ts
105105
// Result: filename.ext
106-
parseFilename('http://example.com/path/to/filename.ext')
106+
parseFilename("http://example.com/path/to/filename.ext");
107107

108108
// Result: undefined
109-
parseFilename('/path/to/.hidden-file', { strict: true })
109+
parseFilename("/path/to/.hidden-file", { strict: true });
110110
```
111111

112112
### `$URL`
@@ -122,7 +122,7 @@ Implementing URL interface with improvements:
122122
- Punycode support for host encoding
123123

124124
```ts
125-
new $URL('http://localhost:3000/hello?world=true')
125+
new $URL("http://localhost:3000/hello?world=true");
126126
// { protocol: 'http:', host: 'localhost:3000', auth: '', pathname: '/hello', query: { world: 'true' }, hash: '' }
127127
```
128128

@@ -131,14 +131,14 @@ new $URL('http://localhost:3000/hello?world=true')
131131
Ensures url ends with a trailing slash.
132132

133133
```ts
134-
withTrailingSlash('/foo')
134+
withTrailingSlash("/foo");
135135
// /foo/
136136
```
137137

138138
Set the second option to `true` to support query parameters:
139139

140140
```ts
141-
withTrailingSlash('/path?query=true', true)
141+
withTrailingSlash("/path?query=true", true);
142142
// /path/?query=true
143143
```
144144

@@ -147,14 +147,14 @@ withTrailingSlash('/path?query=true', true)
147147
Ensures url does not ends with a trailing slash.
148148

149149
```ts
150-
withoutTrailingSlash('/foo/')
150+
withoutTrailingSlash("/foo/");
151151
// /foo
152152
```
153153

154154
Set the second option to `true` to support query parameters:
155155

156156
```ts
157-
withoutTrailingSlash('/path/?query=true', true)
157+
withoutTrailingSlash("/path/?query=true", true);
158158
// /path?query=true
159159
```
160160

@@ -163,10 +163,10 @@ withoutTrailingSlash('/path/?query=true', true)
163163
Ensures url does not have double slash (except for protocol).
164164

165165
```ts
166-
cleanDoubleSlashes('//foo//bar//')
166+
cleanDoubleSlashes("//foo//bar//");
167167
// /foo/bar/
168168

169-
cleanDoubleSlashes('http://example.com/analyze//http://localhost:3000//')
169+
cleanDoubleSlashes("http://example.com/analyze//http://localhost:3000//");
170170
// http://example.com/analyze/http://localhost:3000/
171171
```
172172

@@ -175,7 +175,7 @@ cleanDoubleSlashes('http://example.com/analyze//http://localhost:3000//')
175175
Check two paths are equal or not. Trailing slash and encoding are normalized before comparison.
176176

177177
```ts
178-
isSamePath('/foo', '/foo/')
178+
isSamePath("/foo", "/foo/");
179179
// true
180180
```
181181

@@ -184,7 +184,7 @@ isSamePath('/foo', '/foo/')
184184
Check if a path starts with `./` or `../`.
185185

186186
```ts
187-
isRelative('./foo')
187+
isRelative("./foo");
188188
// true
189189
```
190190

@@ -193,7 +193,7 @@ isRelative('./foo')
193193
Ensures url protocol is `http`
194194

195195
```ts
196-
withHttp('https://example.com')
196+
withHttp("https://example.com");
197197
// http://example.com
198198
```
199199

@@ -202,7 +202,7 @@ withHttp('https://example.com')
202202
Ensures url protocol is `https`
203203

204204
```ts
205-
withHttps('http://example.com')
205+
withHttps("http://example.com");
206206
// https://example.com
207207
```
208208

@@ -211,7 +211,7 @@ withHttps('http://example.com')
211211
Changes url protocol passed as second argument
212212

213213
```ts
214-
withProtocol('http://example.com', 'ftp://')
214+
withProtocol("http://example.com", "ftp://");
215215
// ftp://example.com
216216
```
217217

@@ -220,7 +220,7 @@ withProtocol('http://example.com', 'ftp://')
220220
Removes url protocol
221221

222222
```ts
223-
withoutProtocol('http://example.com')
223+
withoutProtocol("http://example.com");
224224
// example.com
225225
```
226226

@@ -229,19 +229,19 @@ withoutProtocol('http://example.com')
229229
Compare two URLs regardless of their slash condition or encoding:
230230

231231
```ts
232-
isEqual('/foo', 'foo')
232+
isEqual("/foo", "foo");
233233
// true
234-
isEqual('foo/', 'foo')
234+
isEqual("foo/", "foo");
235235
// true
236-
isEqual('/foo bar', '/foo%20bar')
236+
isEqual("/foo bar", "/foo%20bar");
237237
// true
238238

239239
// Strict compare
240-
isEqual('/foo', 'foo', { leadingSlash: true })
240+
isEqual("/foo", "foo", { leadingSlash: true });
241241
// false
242-
isEqual('foo/', 'foo', { trailingSlash: true })
242+
isEqual("foo/", "foo", { trailingSlash: true });
243243
// false
244-
isEqual('/foo bar', '/foo%20bar', { encoding: true })
244+
isEqual("/foo bar", "/foo%20bar", { encoding: true });
245245
// false
246246
```
247247

@@ -250,11 +250,11 @@ isEqual('/foo bar', '/foo%20bar', { encoding: true })
250250
Add a fragment (or hash) to a URL:
251251

252252
```ts
253-
withFragment('/foo', 'bar')
253+
withFragment("/foo", "bar");
254254
// /foo#bar
255-
withFragment('/foo#bar', 'baz')
255+
withFragment("/foo#bar", "baz");
256256
// /foo#baz
257-
withFragment('/foo#bar', '')
257+
withFragment("/foo#bar", "");
258258
// /foo
259259
```
260260

@@ -265,6 +265,7 @@ withFragment('/foo#bar', '')
265265
Special thanks to Eduardo San Martin Morote ([posva](https://github.com/posva)) for [encoding utilities](https://github.com/vuejs/vue-router-next/blob/v4.0.1/src/encoding.ts)
266266

267267
<!-- Badges -->
268+
268269
[npm-version-src]: https://img.shields.io/npm/v/ufo?style=flat&colorA=18181B&colorB=F0DB4F
269270
[npm-version-href]: https://npmjs.com/package/ufo
270271
[npm-downloads-src]: https://img.shields.io/npm/dm/ufo?style=flat&colorA=18181B&colorB=F0DB4F

0 commit comments

Comments
 (0)