vscode-uri
Advanced tools
Comparing version 1.0.5 to 1.0.6
/** | ||
* Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986. | ||
* This class is a simple parser which creates the basic component paths | ||
* This class is a simple parser which creates the basic component parts | ||
* (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation | ||
@@ -14,4 +14,2 @@ * and encoding. | ||
* urn:example:animal:ferret:nose | ||
* | ||
* | ||
*/ | ||
@@ -52,5 +50,23 @@ export default class URI implements UriComponents { | ||
* Returns a string representing the corresponding file system path of this URI. | ||
* Will handle UNC paths and normalize windows drive letters to lower-case. Also | ||
* uses the platform specific path separator. Will *not* validate the path for | ||
* invalid characters and semantics. Will *not* look at the scheme of this URI. | ||
* Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the | ||
* platform specific path separator. | ||
* | ||
* * Will *not* validate the path for invalid characters and semantics. | ||
* * Will *not* look at the scheme of this URI. | ||
* * The result shall *not* be used for display purposes but for accessing a file on disk. | ||
* | ||
* | ||
* The *difference* to `URI#path` is the use of the platform specific separator and the handling | ||
* of UNC paths. See the below sample of a file-uri with an authority (UNC path). | ||
* | ||
* ```ts | ||
const u = URI.parse('file://server/c$/folder/file.txt') | ||
u.authority === 'server' | ||
u.path === '/shares/c$/file.txt' | ||
u.fsPath === '\\server\c$\folder\file.txt' | ||
``` | ||
* | ||
* Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path, | ||
* namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working | ||
* with URIs that represent files on disk (`file` scheme). | ||
*/ | ||
@@ -60,11 +76,39 @@ readonly fsPath: string; | ||
scheme?: string; | ||
authority?: string; | ||
path?: string; | ||
query?: string; | ||
fragment?: string; | ||
authority?: string | null; | ||
path?: string | null; | ||
query?: string | null; | ||
fragment?: string | null; | ||
}): URI; | ||
/** | ||
* Creates a new URI from a string, e.g. `http://www.msft.com/some/path`, | ||
* `file:///usr/home`, or `scheme:with/path`. | ||
* | ||
* @param value A string which represents an URI (see `URI#toString`). | ||
*/ | ||
static parse(value: string): URI; | ||
/** | ||
* Creates a new URI from a file system path, e.g. `c:\my\files`, | ||
* `/usr/home`, or `\\server\share\some\path`. | ||
* | ||
* The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument | ||
* as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as** | ||
* `URI.parse('file://' + path)` because the path might contain characters that are | ||
* interpreted (# and ?). See the following sample: | ||
* ```ts | ||
const good = URI.file('/coding/c#/project1'); | ||
good.scheme === 'file'; | ||
good.path === '/coding/c#/project1'; | ||
good.fragment === ''; | ||
const bad = URI.parse('file://' + '/coding/c#/project1'); | ||
bad.scheme === 'file'; | ||
bad.path === '/coding/c'; // path is now broken | ||
bad.fragment === '/project1'; | ||
``` | ||
* | ||
* @param path A file system path (see `URI#fsPath`) | ||
*/ | ||
static file(path: string): URI; | ||
static from(components: { | ||
scheme?: string; | ||
scheme: string; | ||
authority?: string; | ||
@@ -76,3 +120,10 @@ path?: string; | ||
/** | ||
* Creates a string presentation for this URI. It's guardeed that calling | ||
* `URI.parse` with the result of this function creates an URI which is equal | ||
* to this URI. | ||
* | ||
* * The result shall *not* be used for display purposes but for externalization or transport. | ||
* * The result will be encoded using the percentage encoding and encoding happens mostly | ||
* ignore the scheme-specific encoding rules. | ||
* | ||
* @param skipEncoding Do not encode the result, default is `false` | ||
@@ -79,0 +130,0 @@ */ |
@@ -77,3 +77,3 @@ /*--------------------------------------------------------------------------------------------- | ||
* Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986. | ||
* This class is a simple parser which creates the basic component paths | ||
* This class is a simple parser which creates the basic component parts | ||
* (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation | ||
@@ -89,4 +89,2 @@ * and encoding. | ||
* urn:example:animal:ferret:nose | ||
* | ||
* | ||
*/ | ||
@@ -134,7 +132,28 @@ var URI = (function () { | ||
* Returns a string representing the corresponding file system path of this URI. | ||
* Will handle UNC paths and normalize windows drive letters to lower-case. Also | ||
* uses the platform specific path separator. Will *not* validate the path for | ||
* invalid characters and semantics. Will *not* look at the scheme of this URI. | ||
* Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the | ||
* platform specific path separator. | ||
* | ||
* * Will *not* validate the path for invalid characters and semantics. | ||
* * Will *not* look at the scheme of this URI. | ||
* * The result shall *not* be used for display purposes but for accessing a file on disk. | ||
* | ||
* | ||
* The *difference* to `URI#path` is the use of the platform specific separator and the handling | ||
* of UNC paths. See the below sample of a file-uri with an authority (UNC path). | ||
* | ||
* ```ts | ||
const u = URI.parse('file://server/c$/folder/file.txt') | ||
u.authority === 'server' | ||
u.path === '/shares/c$/file.txt' | ||
u.fsPath === '\\server\c$\folder\file.txt' | ||
``` | ||
* | ||
* Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path, | ||
* namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working | ||
* with URIs that represent files on disk (`file` scheme). | ||
*/ | ||
get: function () { | ||
// if (this.scheme !== 'file') { | ||
// console.warn(`[UriError] calling fsPath with scheme ${this.scheme}`); | ||
// } | ||
return _makeFsPath(this); | ||
@@ -191,2 +210,8 @@ }, | ||
// ---- parse & validate ------------------------ | ||
/** | ||
* Creates a new URI from a string, e.g. `http://www.msft.com/some/path`, | ||
* `file:///usr/home`, or `scheme:with/path`. | ||
* | ||
* @param value A string which represents an URI (see `URI#toString`). | ||
*/ | ||
URI.parse = function (value) { | ||
@@ -199,2 +224,24 @@ var match = _regexp.exec(value); | ||
}; | ||
/** | ||
* Creates a new URI from a file system path, e.g. `c:\my\files`, | ||
* `/usr/home`, or `\\server\share\some\path`. | ||
* | ||
* The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument | ||
* as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as** | ||
* `URI.parse('file://' + path)` because the path might contain characters that are | ||
* interpreted (# and ?). See the following sample: | ||
* ```ts | ||
const good = URI.file('/coding/c#/project1'); | ||
good.scheme === 'file'; | ||
good.path === '/coding/c#/project1'; | ||
good.fragment === ''; | ||
const bad = URI.parse('file://' + '/coding/c#/project1'); | ||
bad.scheme === 'file'; | ||
bad.path === '/coding/c'; // path is now broken | ||
bad.fragment === '/project1'; | ||
``` | ||
* | ||
* @param path A file system path (see `URI#fsPath`) | ||
*/ | ||
URI.file = function (path) { | ||
@@ -228,3 +275,10 @@ var authority = _empty; | ||
/** | ||
* Creates a string presentation for this URI. It's guardeed that calling | ||
* `URI.parse` with the result of this function creates an URI which is equal | ||
* to this URI. | ||
* | ||
* * The result shall *not* be used for display purposes but for externalization or transport. | ||
* * The result will be encoded using the percentage encoding and encoding happens mostly | ||
* ignore the scheme-specific encoding rules. | ||
* | ||
* @param skipEncoding Do not encode the result, default is `false` | ||
@@ -504,3 +558,3 @@ */ | ||
res += '#'; | ||
res += encoder(fragment, false); | ||
res += !skipEncoding ? encodeURIComponentFast(fragment, false) : fragment; | ||
} | ||
@@ -507,0 +561,0 @@ return res; |
/** | ||
* Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986. | ||
* This class is a simple parser which creates the basic component paths | ||
* This class is a simple parser which creates the basic component parts | ||
* (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation | ||
@@ -14,4 +14,2 @@ * and encoding. | ||
* urn:example:animal:ferret:nose | ||
* | ||
* | ||
*/ | ||
@@ -52,5 +50,23 @@ export default class URI implements UriComponents { | ||
* Returns a string representing the corresponding file system path of this URI. | ||
* Will handle UNC paths and normalize windows drive letters to lower-case. Also | ||
* uses the platform specific path separator. Will *not* validate the path for | ||
* invalid characters and semantics. Will *not* look at the scheme of this URI. | ||
* Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the | ||
* platform specific path separator. | ||
* | ||
* * Will *not* validate the path for invalid characters and semantics. | ||
* * Will *not* look at the scheme of this URI. | ||
* * The result shall *not* be used for display purposes but for accessing a file on disk. | ||
* | ||
* | ||
* The *difference* to `URI#path` is the use of the platform specific separator and the handling | ||
* of UNC paths. See the below sample of a file-uri with an authority (UNC path). | ||
* | ||
* ```ts | ||
const u = URI.parse('file://server/c$/folder/file.txt') | ||
u.authority === 'server' | ||
u.path === '/shares/c$/file.txt' | ||
u.fsPath === '\\server\c$\folder\file.txt' | ||
``` | ||
* | ||
* Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path, | ||
* namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working | ||
* with URIs that represent files on disk (`file` scheme). | ||
*/ | ||
@@ -60,11 +76,39 @@ readonly fsPath: string; | ||
scheme?: string; | ||
authority?: string; | ||
path?: string; | ||
query?: string; | ||
fragment?: string; | ||
authority?: string | null; | ||
path?: string | null; | ||
query?: string | null; | ||
fragment?: string | null; | ||
}): URI; | ||
/** | ||
* Creates a new URI from a string, e.g. `http://www.msft.com/some/path`, | ||
* `file:///usr/home`, or `scheme:with/path`. | ||
* | ||
* @param value A string which represents an URI (see `URI#toString`). | ||
*/ | ||
static parse(value: string): URI; | ||
/** | ||
* Creates a new URI from a file system path, e.g. `c:\my\files`, | ||
* `/usr/home`, or `\\server\share\some\path`. | ||
* | ||
* The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument | ||
* as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as** | ||
* `URI.parse('file://' + path)` because the path might contain characters that are | ||
* interpreted (# and ?). See the following sample: | ||
* ```ts | ||
const good = URI.file('/coding/c#/project1'); | ||
good.scheme === 'file'; | ||
good.path === '/coding/c#/project1'; | ||
good.fragment === ''; | ||
const bad = URI.parse('file://' + '/coding/c#/project1'); | ||
bad.scheme === 'file'; | ||
bad.path === '/coding/c'; // path is now broken | ||
bad.fragment === '/project1'; | ||
``` | ||
* | ||
* @param path A file system path (see `URI#fsPath`) | ||
*/ | ||
static file(path: string): URI; | ||
static from(components: { | ||
scheme?: string; | ||
scheme: string; | ||
authority?: string; | ||
@@ -76,3 +120,10 @@ path?: string; | ||
/** | ||
* Creates a string presentation for this URI. It's guardeed that calling | ||
* `URI.parse` with the result of this function creates an URI which is equal | ||
* to this URI. | ||
* | ||
* * The result shall *not* be used for display purposes but for externalization or transport. | ||
* * The result will be encoded using the percentage encoding and encoding happens mostly | ||
* ignore the scheme-specific encoding rules. | ||
* | ||
* @param skipEncoding Do not encode the result, default is `false` | ||
@@ -79,0 +130,0 @@ */ |
@@ -87,3 +87,3 @@ var __extends = (this && this.__extends) || (function () { | ||
* Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986. | ||
* This class is a simple parser which creates the basic component paths | ||
* This class is a simple parser which creates the basic component parts | ||
* (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation | ||
@@ -99,4 +99,2 @@ * and encoding. | ||
* urn:example:animal:ferret:nose | ||
* | ||
* | ||
*/ | ||
@@ -144,7 +142,28 @@ var URI = (function () { | ||
* Returns a string representing the corresponding file system path of this URI. | ||
* Will handle UNC paths and normalize windows drive letters to lower-case. Also | ||
* uses the platform specific path separator. Will *not* validate the path for | ||
* invalid characters and semantics. Will *not* look at the scheme of this URI. | ||
* Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the | ||
* platform specific path separator. | ||
* | ||
* * Will *not* validate the path for invalid characters and semantics. | ||
* * Will *not* look at the scheme of this URI. | ||
* * The result shall *not* be used for display purposes but for accessing a file on disk. | ||
* | ||
* | ||
* The *difference* to `URI#path` is the use of the platform specific separator and the handling | ||
* of UNC paths. See the below sample of a file-uri with an authority (UNC path). | ||
* | ||
* ```ts | ||
const u = URI.parse('file://server/c$/folder/file.txt') | ||
u.authority === 'server' | ||
u.path === '/shares/c$/file.txt' | ||
u.fsPath === '\\server\c$\folder\file.txt' | ||
``` | ||
* | ||
* Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path, | ||
* namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working | ||
* with URIs that represent files on disk (`file` scheme). | ||
*/ | ||
get: function () { | ||
// if (this.scheme !== 'file') { | ||
// console.warn(`[UriError] calling fsPath with scheme ${this.scheme}`); | ||
// } | ||
return _makeFsPath(this); | ||
@@ -201,2 +220,8 @@ }, | ||
// ---- parse & validate ------------------------ | ||
/** | ||
* Creates a new URI from a string, e.g. `http://www.msft.com/some/path`, | ||
* `file:///usr/home`, or `scheme:with/path`. | ||
* | ||
* @param value A string which represents an URI (see `URI#toString`). | ||
*/ | ||
URI.parse = function (value) { | ||
@@ -209,2 +234,24 @@ var match = _regexp.exec(value); | ||
}; | ||
/** | ||
* Creates a new URI from a file system path, e.g. `c:\my\files`, | ||
* `/usr/home`, or `\\server\share\some\path`. | ||
* | ||
* The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument | ||
* as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as** | ||
* `URI.parse('file://' + path)` because the path might contain characters that are | ||
* interpreted (# and ?). See the following sample: | ||
* ```ts | ||
const good = URI.file('/coding/c#/project1'); | ||
good.scheme === 'file'; | ||
good.path === '/coding/c#/project1'; | ||
good.fragment === ''; | ||
const bad = URI.parse('file://' + '/coding/c#/project1'); | ||
bad.scheme === 'file'; | ||
bad.path === '/coding/c'; // path is now broken | ||
bad.fragment === '/project1'; | ||
``` | ||
* | ||
* @param path A file system path (see `URI#fsPath`) | ||
*/ | ||
URI.file = function (path) { | ||
@@ -238,3 +285,10 @@ var authority = _empty; | ||
/** | ||
* Creates a string presentation for this URI. It's guardeed that calling | ||
* `URI.parse` with the result of this function creates an URI which is equal | ||
* to this URI. | ||
* | ||
* * The result shall *not* be used for display purposes but for externalization or transport. | ||
* * The result will be encoded using the percentage encoding and encoding happens mostly | ||
* ignore the scheme-specific encoding rules. | ||
* | ||
* @param skipEncoding Do not encode the result, default is `false` | ||
@@ -514,3 +568,3 @@ */ | ||
res += '#'; | ||
res += encoder(fragment, false); | ||
res += !skipEncoding ? encodeURIComponentFast(fragment, false) : fragment; | ||
} | ||
@@ -517,0 +571,0 @@ return res; |
{ | ||
"name": "vscode-uri", | ||
"author": "Microsoft", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "The URI implementation that is used by VS Code and its extensions", | ||
@@ -6,0 +6,0 @@ "main": "./lib/umd/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
57857
1395
0
9