Skip to content

Commit dcccd9e

Browse files
committed
Fix location links being displayed for query results with empty file:/// URI
1 parent 534c051 commit dcccd9e

File tree

4 files changed

+31
-13
lines changed

4 files changed

+31
-13
lines changed

extensions/ql-vscode/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## [UNRELEASED]
44

55
- Remove support for CodeQL CLI versions older than 2.22.4. [#4344](https://github.com/github/vscode-codeql/pull/4344)
6+
- Fix location links being displayed for query results with empty `file:///` URI [#4357](https://github.com/github/vscode-codeql/pull/4357)
67

78
## 1.17.7 - 5 December 2025
89

extensions/ql-vscode/src/common/bqrs-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { isUrlValueResolvable } from "./raw-result-types";
77
* as a link.
88
*/
99
export function isEmptyPath(uriStr: string) {
10-
return !uriStr || uriStr === "file:/";
10+
return !uriStr || uriStr === "file:/" || uriStr === "file:///";
1111
}
1212

1313
export function tryGetRemoteLocation(

extensions/ql-vscode/test/unit-tests/common/bqrs-raw-results-mapper.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
} from "../../../src/common/bqrs-raw-results-mapper";
55
import type {
66
BqrsResultSetSchema,
7+
BqrsWholeFileLocation,
78
DecodedBqrsChunk,
89
} from "../../../src/common/bqrs-cli-types";
910
import { ColumnKind } from "../../../src/common/raw-result-types";
@@ -319,4 +320,18 @@ describe("mapUrlValue", () => {
319320
});
320321
}
321322
});
323+
324+
it("should return undefined for empty file uri", () => {
325+
for (const fileUri of ["file:/", "file:///"]) {
326+
const loc = {
327+
uri: fileUri,
328+
startLine: 0,
329+
startColumn: 0,
330+
endLine: 0,
331+
endColumn: 0,
332+
} as BqrsWholeFileLocation;
333+
const urlValue = mapUrlValue(loc);
334+
expect(urlValue).toBeUndefined();
335+
}
336+
});
322337
});

extensions/ql-vscode/test/vscode-tests/no-workspace/language-support/contextual/file-range-from-uri.test.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,20 @@ describe("fileRangeFromURI", () => {
4646
});
4747

4848
it("should return undefined when value is an empty uri", () => {
49-
expect(
50-
fileRangeFromURI(
51-
{
52-
uri: "file:/",
53-
startLine: 1,
54-
startColumn: 2,
55-
endLine: 3,
56-
endColumn: 4,
57-
} as BqrsLineColumnLocation,
58-
createMockDatabaseItem(),
59-
),
60-
).toBeUndefined();
49+
for (const fileUri of ["file:/", "file:///"]) {
50+
expect(
51+
fileRangeFromURI(
52+
{
53+
uri: fileUri,
54+
startLine: 1,
55+
startColumn: 2,
56+
endLine: 3,
57+
endColumn: 4,
58+
} as BqrsLineColumnLocation,
59+
createMockDatabaseItem(),
60+
),
61+
).toBeUndefined();
62+
}
6163
});
6264

6365
it("should return a range for a WholeFileLocation", () => {

0 commit comments

Comments
 (0)