blob: af8e9f8f540f7b814f280053de46023ab1af13fb [file] [log] [blame] [view]
Danil Somsikov058b9d82024-10-07 11:22:191## vscode-uri
2
3[![Build Status](https://travis-ci.org/Microsoft/vscode-uri.svg?branch=master)](https://travis-ci.org/Microsoft/vscode-uri)
4
5This module contains the URI implementation that is used by VS Code and its extensions.
6It has support for parsing a string into `scheme`, `authority`, `path`, `query`, and
7`fragment` URI components as defined in: http://tools.ietf.org/html/rfc3986
8
9```
10 foo://example.com:8042/over/there?name=ferret#nose
11 \_/ \______________/\_________/ \_________/ \__/
12 | | | | |
13scheme authority path query fragment
14 | _____________________|__
15 / \ / \
16 urn:example:animal:ferret:nose
17```
18
19## Usage
20
21```js
22import { URI } from 'vscode-uri'
23
24// parse an URI from string
25
26let uri = URI.parse('https://code.visualstudio.com/docs/extensions/overview#frag')
27
28assert.ok(uri.scheme === 'https');
29assert.ok(uri.authority === 'code.visualstudio.com');
30assert.ok(uri.path === '/docs/extensions/overview');
31assert.ok(uri.query === '');
32assert.ok(uri.fragment === 'frag');
33assert.ok(uri.toString() === 'https://code.visualstudio.com/docs/extensions/overview#frag')
34
35
36// create an URI from a fs path
37
38let uri = URI.file('/users/me/c#-projects/');
39
40assert.ok(uri.scheme === 'file');
41assert.ok(uri.authority === '');
42assert.ok(uri.path === '/users/me/c#-projects/');
43assert.ok(uri.query === '');
44assert.ok(uri.fragment === '');
45assert.ok(uri.toString() === 'file:///users/me/c%23-projects/')
46```
47
48## Contributing
49
50The source of this module is taken straight from the [vscode](https://github.com/Microsoft/vscode)-sources and because of that issues and pull request should be created in that repository. Thanks and Happy Coding!
51
52## Code of Conduct
53
54This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [[email protected]](mailto:[email protected]) with any additional questions or comments.