Path: blob/main/extensions/markdown-language-features/src/util/uriList.ts
3292 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { coalesce } from './arrays';6import * as vscode from 'vscode';78function splitUriList(str: string): string[] {9return str.split('\r\n');10}1112function parseUriList(str: string): string[] {13return splitUriList(str)14.filter(value => !value.startsWith('#')) // Remove comments15.map(value => value.trim());16}1718export class UriList {1920static from(str: string): UriList {21return new UriList(coalesce(parseUriList(str).map(line => {22try {23return { uri: vscode.Uri.parse(line), str: line };24} catch {25// Uri parse failure26return undefined;27}28})));29}3031private constructor(32public readonly entries: ReadonlyArray<{ readonly uri: vscode.Uri; readonly str: string }>33) { }34}353637