Skip to content

Commit e8a4393

Browse files
committed
more URI over URL changes, remove getPath and getRequestUrl from request service
1 parent 58cd13b commit e8a4393

4 files changed

Lines changed: 11 additions & 58 deletions

File tree

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
'use strict';
66

77
import * as assert from 'assert';
8+
import URI from 'vs/base/common/uri';
89
import { URL, ParsedUrl } from 'vs/base/common/network';
910
import { serialize, deserialize } from 'vs/base/common/marshalling';
1011

@@ -20,6 +21,14 @@ function assertUrl(raw:string, scheme:string, domain:string, port:string, path:s
2021
assert.equal(url.getPath(), path, 'getPath ok for ' + raw);
2122
assert.equal(url.getQueryString(), queryString, 'getQueryString ok for ' + raw);
2223
assert.equal(url.getFragmentId(), fragmentId, 'getFragmentId ok for ' + raw);
24+
25+
// check for equivalent behaviour
26+
var uri = URI.parse(raw);
27+
assert.equal(uri.scheme, scheme);
28+
assert.equal(uri.authority, port ? domain + ':' + port : domain);
29+
assert.equal(uri.path, path);
30+
assert.equal(uri.query, queryString);
31+
assert.equal(uri.fragment, fragmentId);
2332
}
2433

2534
function assertCombine(base:string, relativeUrl:string, expectedUrl:string): void {

src/vs/editor/browser/standalone/simpleServices.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,6 @@ export class SimpleEditorRequestService extends BaseRequestService {
208208
constructor(contextService: IWorkspaceContextService, telemetryService?: ITelemetryService) {
209209
super(contextService, telemetryService);
210210
}
211-
212-
public getPath(service:string, requestUrl:URI):string {
213-
return requestUrl.toString(); // Standalone Editor talks about URLs that never have a path
214-
}
215211
}
216212

217213
export class StandaloneKeybindingService extends KeybindingService.KeybindingService {

src/vs/platform/request/common/baseRequestService.ts

Lines changed: 2 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55
'use strict';
66

7-
import network = require('vs/base/common/network');
7+
import URI from 'vs/base/common/uri';
88
import strings = require('vs/base/common/strings');
99
import Timer = require('vs/base/common/timer');
1010
import Async = require('vs/base/common/async');
@@ -46,7 +46,7 @@ export class BaseRequestService implements IRequestService {
4646

4747
// Find root server URL from configuration
4848
this._origin = workspaceUri;
49-
var urlPath = new network.URL(this._origin).getPath();
49+
var urlPath = URI.parse(this._origin).path;
5050
if (urlPath && urlPath.length > 0) {
5151
this._origin = this._origin.substring(0, this._origin.length - urlPath.length + 1);
5252
}
@@ -59,44 +59,6 @@ export class BaseRequestService implements IRequestService {
5959
}
6060
}
6161

62-
public getRequestUrl(service:string, path?:string, absolute?:boolean):string {
63-
if (this._serviceMap[service]) {
64-
var serviceUrl = this._serviceMap[service] + strings.normalizePath(path);
65-
66-
var fullUrl = new network.URL(serviceUrl);
67-
if (fullUrl.getScheme()) {
68-
return serviceUrl;
69-
}
70-
71-
// request URL relative to server
72-
if (!absolute) {
73-
return serviceUrl;
74-
}
75-
76-
// absolute request URL
77-
return this._origin + strings.ltrim(serviceUrl, '/');
78-
}
79-
80-
return null;
81-
}
82-
83-
public getPath(service:string, requestUrl:network.URL):string {
84-
85-
// Find service root
86-
var serviceRoot = this.getRequestUrl(service, '/', true);
87-
if (!serviceRoot) {
88-
return null;
89-
}
90-
91-
// Substr path
92-
var index = requestUrl.toString().indexOf(serviceRoot);
93-
if (index === 0) {
94-
return requestUrl.toString().substr(serviceRoot.length - 1); // Keep leading slash
95-
}
96-
97-
return null;
98-
}
99-
10062
protected makeCrossOriginRequest(options:http.IXHROptions): winjs.TPromise<http.IXHRResponse> {
10163
return null;
10264
}

src/vs/platform/request/common/request.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,6 @@ export var IRequestService = createDecorator<IRequestService>('requestService');
1414
export interface IRequestService {
1515
serviceId : ServiceIdentifier<any>;
1616

17-
/**
18-
* Returns the URL that can be used to access the provided service. The optional second argument can
19-
* be provided to narrow down the request URL to a specific file system resource. The third argument
20-
* allows to specify to return a fully absolute server URL.
21-
*/
22-
getRequestUrl(service:string, path?:string, absolute?:boolean):string;
23-
24-
/**
25-
* Returns the path from the given requestUrl using the provided service identifier. The path will match
26-
* the path that was passed in to IRequestService#getRequestUrl() or null if it can not be identified. Path
27-
* always begins with a leading slash.
28-
*/
29-
getPath(service:string, requestUrl:URI):string;
30-
3117
/**
3218
* Wraps the call into WinJS.XHR to allow for mocking and telemetry. Use this instead
3319
* of calling WinJS.XHR directly.

0 commit comments

Comments
 (0)