The URI implementation that is used in VS Code and its extensions.
Перейти к файлу
SteVen Batten 4a541cede1
Batch ci
2023-03-28 09:53:03 -04:00
.github/workflows Update to latest indexer 2021-12-02 15:37:08 +01:00
.vscode clearly separate what's vscode.Uri-like what's an extending utility 2020-12-17 11:51:02 +00:00
src update to latest version (#32) 2022-12-12 09:32:49 +01:00
.gitignore Add lsif configuration 2021-09-30 20:34:48 +02:00
.lsifrc.json Add lsif configuration 2021-09-30 20:34:48 +02:00
.mocharc.json add path utils 2020-09-25 14:19:53 +02:00
.npmignore bring in path through webpack 2020-09-28 12:22:15 +02:00
.travis.yml prepare 3.0.4 (#27) 2022-09-15 09:59:34 +02:00
LICENSE.md add license file 2016-06-07 16:18:14 +02:00
README.md update readme 2020-12-17 15:32:10 +00:00
package.json update to latest version (#32) 2022-12-12 09:32:49 +01:00
pipeline.yml Batch ci 2023-03-28 09:53:03 -04:00
webpack.config.js vscode-uri (3.0.5): Incorrect Types (#29) 2022-09-19 15:25:52 +02:00
yarn.lock infrastructure work (#30) 2022-11-01 16:48:22 +01:00

README.md

vscode-uri

Build Status

This module contains the URI implementation that is used by VS Code and its extensions. It has support for parsing a string into scheme, authority, path, query, and fragment URI components as defined in: http://tools.ietf.org/html/rfc3986

  foo://example.com:8042/over/there?name=ferret#nose
  \_/   \______________/\_________/ \_________/ \__/
   |           |            |            |        |
scheme     authority       path        query   fragment
   |   _____________________|__
  / \ /                        \
  urn:example:animal:ferret:nose

Usage

import { URI } from 'vscode-uri'

// parse an URI from string

let uri = URI.parse('https://code.visualstudio.com/docs/extensions/overview#frag')

assert.ok(uri.scheme === 'https');
assert.ok(uri.authority === 'code.visualstudio.com');
assert.ok(uri.path === '/docs/extensions/overview');
assert.ok(uri.query === '');
assert.ok(uri.fragment === 'frag');
assert.ok(uri.toString() === 'https://code.visualstudio.com/docs/extensions/overview#frag')


// create an URI from a fs path

let uri = URI.file('/users/me/c#-projects/');

assert.ok(uri.scheme === 'file');
assert.ok(uri.authority === '');
assert.ok(uri.path === '/users/me/c#-projects/');
assert.ok(uri.query === '');
assert.ok(uri.fragment === '');
assert.ok(uri.toString() === 'file:///users/me/c%23-projects/')

Usage: Util

This module also exports a Utils package which is an extension, not part of vscode.Uri, and useful for path-math. There is:

  • Utils.joinPath(URI, paths): URI
  • Utils.resolvePath(URI, paths): URI
  • Utils.dirname(URI): string
  • Utils.basename(URI): string
  • Utils.extname(URI): string

All util use posix path-math as defined by the node.js path module.

Contributing

The source of this module is taken straight from the vscode-sources and because of that issues and pull request should be created in that repository. Thanks and Happy Coding!

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.