diff --git a/app/exec/build/tasks/create.ts b/app/exec/build/tasks/create.ts index 7d500f4a..4eda73d4 100644 --- a/app/exec/build/tasks/create.ts +++ b/app/exec/build/tasks/create.ts @@ -5,7 +5,7 @@ import path = require("path"); import shell = require("shelljs"); import tasksBase = require("./default"); import trace = require("../../../lib/trace"); -import { v1 as uuidv1 } from "uuid"; +import uuid = require("uuid"); export interface TaskCreateResult { taskPath: string; @@ -81,7 +81,7 @@ export class TaskCreate extends tasksBase.BuildTaskBase { trace.debug("creating definition"); let def: any = {}; - def.id = uuidv1(); + def.id = uuid.v1(); trace.debug("id: " + def.id); def.name = taskName; trace.debug("name: " + def.name); diff --git a/app/lib/connection.ts b/app/lib/connection.ts index daf1cdef..96a2d112 100644 --- a/app/lib/connection.ts +++ b/app/lib/connection.ts @@ -11,20 +11,14 @@ export class TfsConnection { private collectionUrl: string; constructor(private serviceUrl: string) { - // Parse URL, but handle failures gracefully to mimic url.parse() behavior try { this.parsedUrl = new URL(this.serviceUrl); } catch (error) { - // Mimic url.parse() behavior for invalid URLs - // url.parse() would return an object with null/empty values instead of throwing - this.parsedUrl = { - protocol: this.serviceUrl && this.serviceUrl.includes('://') ? this.serviceUrl.split('://')[0] + ':' : '', - host: null, - hostname: null, - pathname: this.serviceUrl && !this.serviceUrl.includes('://') ? this.serviceUrl : '', - search: '', - hash: '' - } as any; + if (error.code === "ERR_INVALID_URL") { + throw new Error("Please enter a fully-qualified URL.") + } else { + throw error; + } } var splitPath: string[] = this.parsedUrl.pathname.split("/").slice(1); diff --git a/tests/mock-server/utils/RequestParser.ts b/tests/mock-server/utils/RequestParser.ts index 1709ba28..5a5e6141 100644 --- a/tests/mock-server/utils/RequestParser.ts +++ b/tests/mock-server/utils/RequestParser.ts @@ -13,12 +13,7 @@ export class RequestParser { const method = req.method || 'GET'; const pathname = parsedUrl.pathname || ''; - // Parse query parameters using forEach (guaranteed to be available) - const query: { [key: string]: string } = {}; - parsedUrl.searchParams.forEach((value, key) => { - query[key] = value; - }); - + const query = Object.fromEntries(parsedUrl.searchParams.entries()); const contentType = req.headers['content-type'] || ''; if (method === 'GET' || method === 'DELETE' || method === 'OPTIONS') {