Danil Somsikov | 058b9d8 | 2024-10-07 11:22:19 | [diff] [blame] | 1 | ## vscode-uri |
| 2 | |
| 3 | [](https://travis-ci.org/Microsoft/vscode-uri) |
| 4 | |
| 5 | This module contains the URI implementation that is used by VS Code and its extensions. |
| 6 | It 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 | | | | | | |
| 13 | scheme authority path query fragment |
| 14 | | _____________________|__ |
| 15 | / \ / \ |
| 16 | urn:example:animal:ferret:nose |
| 17 | ``` |
| 18 | |
| 19 | ## Usage |
| 20 | |
| 21 | ```js |
| 22 | import { URI } from 'vscode-uri' |
| 23 | |
| 24 | // parse an URI from string |
| 25 | |
| 26 | let uri = URI.parse('https://code.visualstudio.com/docs/extensions/overview#frag') |
| 27 | |
| 28 | assert.ok(uri.scheme === 'https'); |
| 29 | assert.ok(uri.authority === 'code.visualstudio.com'); |
| 30 | assert.ok(uri.path === '/docs/extensions/overview'); |
| 31 | assert.ok(uri.query === ''); |
| 32 | assert.ok(uri.fragment === 'frag'); |
| 33 | assert.ok(uri.toString() === 'https://code.visualstudio.com/docs/extensions/overview#frag') |
| 34 | |
| 35 | |
| 36 | // create an URI from a fs path |
| 37 | |
| 38 | let uri = URI.file('/users/me/c#-projects/'); |
| 39 | |
| 40 | assert.ok(uri.scheme === 'file'); |
| 41 | assert.ok(uri.authority === ''); |
| 42 | assert.ok(uri.path === '/users/me/c#-projects/'); |
| 43 | assert.ok(uri.query === ''); |
| 44 | assert.ok(uri.fragment === ''); |
| 45 | assert.ok(uri.toString() === 'file:///users/me/c%23-projects/') |
| 46 | ``` |
| 47 | |
| 48 | ## Contributing |
| 49 | |
| 50 | The 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 | |
| 54 | This 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. |