From e2b2cfd7ca461760046f3cedee3a3cd3f610f155 Mon Sep 17 00:00:00 2001 From: Cory Rivera Date: Mon, 24 May 2021 10:03:52 -0700 Subject: [PATCH] Fix notebook file URI test by adding a required forward slash to Windows file paths. (#15550) --- .../src/test/protocol/notebookUriHandler.test.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/extensions/notebook/src/test/protocol/notebookUriHandler.test.ts b/extensions/notebook/src/test/protocol/notebookUriHandler.test.ts index 83f7e5d1d7..2823dda0d5 100644 --- a/extensions/notebook/src/test/protocol/notebookUriHandler.test.ts +++ b/extensions/notebook/src/test/protocol/notebookUriHandler.test.ts @@ -19,6 +19,7 @@ import * as constants from '../../common/constants'; import { NotebookUriHandler } from '../../protocol/notebookUriHandler'; import { CellTypes } from '../../contracts/content'; +import { winPlatform } from '../../common/constants'; describe('Notebook URI Handler', function (): void { let notebookUriHandler: NotebookUriHandler; @@ -127,7 +128,14 @@ describe('Notebook URI Handler', function (): void { let notebookPath: string = path.join(notebookDir, 'hello.ipynb'); await fs.mkdir(notebookDir); - let fileURI = 'azuredatastudio://microsoft.notebook/open?url=file://' + notebookPath; + let baseUrl = 'azuredatastudio://microsoft.notebook/open?url=file://'; + if (process.platform === winPlatform) { + // URI paths are formatted as "hostname/path", but since we're using a local path + // we omit the host part and just add the slash. Unix paths already start with a + // forward slash, but we have to prepend it manually when using Windows paths. + baseUrl = baseUrl + '/'; + } + let fileURI = baseUrl + notebookPath; let fileNotebookUri = vscode.Uri.parse(fileURI); let notebookContent: azdata.nb.INotebookContents = { cells: [{