Skip to content

Commit c4fe803

Browse files
committed
Revert "Centralize query parameter cleaning /cc @bpasero and @aeschli"
This reverts commit 0b87133.
1 parent 33873f4 commit c4fe803

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

src/vs/base/common/resources.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,7 @@ export class ExtUri implements IExtUri {
195195
}
196196

197197
extname(resource: URI): string {
198-
const resourceExt = paths.posix.extname(resource.path);
199-
const queryStringLocation = resourceExt.indexOf('?');
200-
return queryStringLocation !== -1 ? resourceExt.substr(0, queryStringLocation) : resourceExt;
198+
return paths.posix.extname(resource.path);
201199
}
202200

203201
dirname(resource: URI): URI {

src/vs/base/test/common/resources.test.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import * as assert from 'assert';
66
import { toSlashes } from 'vs/base/common/extpath';
77
import { posix, win32 } from 'vs/base/common/path';
88
import { isWindows } from 'vs/base/common/platform';
9-
import { addTrailingPathSeparator, basename, dirname, distinctParents, extname, extUri, extUriIgnorePathCase, hasTrailingPathSeparator, isAbsolutePath, joinPath, normalizePath, relativePath, removeTrailingPathSeparator, resolvePath } from 'vs/base/common/resources';
9+
import { addTrailingPathSeparator, basename, dirname, distinctParents, extUri, extUriIgnorePathCase, hasTrailingPathSeparator, isAbsolutePath, joinPath, normalizePath, relativePath, removeTrailingPathSeparator, resolvePath } from 'vs/base/common/resources';
1010
import { URI } from 'vs/base/common/uri';
1111

1212

@@ -429,11 +429,4 @@ suite('Resources', () => {
429429
assert.strictEqual(extUriIgnorePathCase.isEqualOrParent(fileURI7, fileURI6), true, '19');
430430
assert.strictEqual(extUriIgnorePathCase.isEqualOrParent(fileURI7, fileURI5), false, '20');
431431
});
432-
433-
test('query parameters stripped from extname', () => {
434-
const uriWithQueryParam = URI.file('/test/project/test.txt?q=1');
435-
const uriWithoutQueryParam = URI.file('/test/project/test.txt');
436-
assert.strictEqual(extname(uriWithQueryParam), '.txt');
437-
assert.strictEqual(extname(uriWithoutQueryParam), '.txt');
438-
});
439432
});

src/vs/workbench/browser/parts/editor/editorGroupView.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,9 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
631631
const path = resource ? resource.scheme === Schemas.file ? resource.fsPath : resource.path : undefined;
632632
if (resource && path) {
633633
let resourceExt = extname(resource);
634+
// Remove query parameters from the resource extension
635+
const queryStringLocation = resourceExt.indexOf('?');
636+
resourceExt = queryStringLocation !== -1 ? resourceExt.substr(0, queryStringLocation) : resourceExt;
634637
descriptor['resource'] = { mimeType: guessMimeTypes(resource).join(', '), scheme: resource.scheme, ext: resourceExt, path: hash(path) };
635638

636639
/* __GDPR__FRAGMENT__

src/vs/workbench/contrib/telemetry/browser/telemetry.contribution.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ export class TelemetryContribution extends Disposable implements IWorkbenchContr
194194
}
195195

196196
private getTelemetryData(resource: URI, reason?: number): TelemetryData {
197-
const ext = extname(resource);
197+
let ext = extname(resource);
198+
// Remove query parameters from the resource extension
199+
const queryStringLocation = ext.indexOf('?');
200+
ext = queryStringLocation !== -1 ? ext.substr(0, queryStringLocation) : ext;
198201
const fileName = basename(resource);
199202
const path = resource.scheme === Schemas.file ? resource.fsPath : resource.path;
200203
const telemetryData = {

0 commit comments

Comments
 (0)