Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/markdown-language-features/src/util/uriList.ts
3292 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { coalesce } from './arrays';
7
import * as vscode from 'vscode';
8
9
function splitUriList(str: string): string[] {
10
return str.split('\r\n');
11
}
12
13
function parseUriList(str: string): string[] {
14
return splitUriList(str)
15
.filter(value => !value.startsWith('#')) // Remove comments
16
.map(value => value.trim());
17
}
18
19
export class UriList {
20
21
static from(str: string): UriList {
22
return new UriList(coalesce(parseUriList(str).map(line => {
23
try {
24
return { uri: vscode.Uri.parse(line), str: line };
25
} catch {
26
// Uri parse failure
27
return undefined;
28
}
29
})));
30
}
31
32
private constructor(
33
public readonly entries: ReadonlyArray<{ readonly uri: vscode.Uri; readonly str: string }>
34
) { }
35
}
36
37