Skip to content

Commit

Permalink
Normalize colons in Windows paths
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed May 19, 2021
1 parent fa23d8f commit d0d9962
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/jupyterlab-lsp/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { PageConfig } from '@jupyterlab/coreutils';
import { ReadonlyJSONObject, ReadonlyJSONValue } from '@lumino/coreutils';
import mergeWith from 'lodash.mergewith';

const RE_PATH_ANCHOR = /^file:\/\/([^\/]+|\/[A-Z]:)/;
const RE_PATH_ANCHOR = /^file:\/\/([^\/]+|\/[a-zA-Z](?::|%3A))/;

export async function sleep(timeout: number) {
return new Promise<void>(resolve => {
Expand Down Expand Up @@ -142,7 +142,11 @@ export function is_win_path(uri: string) {
* lowercase the drive component of a URI
*/
export function normalize_win_path(uri: string) {
return uri.replace(RE_PATH_ANCHOR, it => it.toLowerCase());
// Pyright encodes colon on Windows, see:
// https://github.com/krassowski/jupyterlab-lsp/pull/587#issuecomment-844225253
return uri.replace(RE_PATH_ANCHOR, it =>
it.toLowerCase().replace('%3A', ':')
);
}

export function uri_to_contents_path(child: string, parent?: string) {
Expand Down

0 comments on commit d0d9962

Please sign in to comment.