|
1 | 1 | import * as path from 'vs/base/common/path'; |
2 | | -import { URI } from 'vs/base/common/uri'; |
3 | 2 | import { Options } from 'vs/ipc'; |
4 | 3 | import { localize } from 'vs/nls'; |
5 | 4 | import { MenuId, MenuRegistry } from 'vs/platform/actions/common/actions'; |
@@ -209,37 +208,3 @@ export const initialize = async (services: ServiceCollection): Promise<void> => |
209 | 208 | when: ContextKeyExpr.has('code-server.authed') |
210 | 209 | }); |
211 | 210 | }; |
212 | | - |
213 | | -export interface Query { |
214 | | - [key: string]: string | undefined; |
215 | | -} |
216 | | - |
217 | | -/** |
218 | | - * Split a string up to the delimiter. If the delimiter doesn't exist the first |
219 | | - * item will have all the text and the second item will be an empty string. |
220 | | - */ |
221 | | -export const split = (str: string, delimiter: string): [string, string] => { |
222 | | - const index = str.indexOf(delimiter); |
223 | | - return index !== -1 ? [str.substring(0, index).trim(), str.substring(index + 1)] : [str, '']; |
224 | | -}; |
225 | | - |
226 | | -/** |
227 | | - * Return the URL modified with the specified query variables. It's pretty |
228 | | - * stupid so it probably doesn't cover any edge cases. Undefined values will |
229 | | - * unset existing values. Doesn't allow duplicates. |
230 | | - */ |
231 | | -export const withQuery = (url: string, replace: Query): string => { |
232 | | - const uri = URI.parse(url); |
233 | | - const query = { ...replace }; |
234 | | - uri.query.split('&').forEach((kv) => { |
235 | | - const [key, value] = split(kv, '='); |
236 | | - if (!(key in query)) { |
237 | | - query[key] = value; |
238 | | - } |
239 | | - }); |
240 | | - return uri.with({ |
241 | | - query: Object.keys(query) |
242 | | - .filter((k) => typeof query[k] !== 'undefined') |
243 | | - .map((k) => `${k}=${query[k]}`).join('&'), |
244 | | - }).toString(true); |
245 | | -}; |
0 commit comments