The URI implementation that is used in VS Code and its extensions.
TypeScript
Clone or download
Latest commit a52018b Jun 6, 2018
Permalink
Failed to load latest commit information.
.vscode update to TypeScript 2.0, bump major version Sep 26, 2016
src update to latest uri-impl Jun 6, 2018
.gitignore ESM Support Mar 7, 2018
.npmignore ESM Support Mar 7, 2018
.travis.yml tweak travis script Jun 13, 2016
LICENSE.md add license file Jun 7, 2016
README.md update readme Jun 16, 2017
package-lock.json ESM Support Mar 7, 2018
package.json 1.0.5 Jun 6, 2018

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/')

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.