Skip to content

Commit dab714d

Browse files
authored
fix: GitHub MCP / VS Code extension registry enforcing -d (#519)
Github MCP registry links to VS Code extension that always enforce -d param (domains), thus here treating empty for empty confirmation. <img width="2457" height="517" alt="image" src="https://github.com/user-attachments/assets/48c60f40-df78-4598-a699-510bc14476e0" /> If press enter other than the skip, it leads to null issue. This aims to patch it. <img width="2464" height="492" alt="image" src="https://github.com/user-attachments/assets/209ace4b-bde0-4c02-901a-8c96c11b09a1" />
1 parent dfee3a8 commit dab714d

File tree

2 files changed

+32
-6
lines changed

2 files changed

+32
-6
lines changed

src/shared/domains.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ export class DomainsManager {
122122
* @returns Normalized array of domain strings
123123
*/
124124
public static parseDomainsInput(domainsInput?: string | string[]): string[] {
125-
if (!domainsInput) {
126-
return [];
125+
if (!domainsInput || this.isEmptyDomainsInput(domainsInput)) {
126+
return ["all"];
127127
}
128128

129129
if (typeof domainsInput === "string") {
@@ -132,4 +132,10 @@ export class DomainsManager {
132132

133133
return domainsInput.map((d) => d.trim().toLowerCase());
134134
}
135+
136+
private static isEmptyDomainsInput(domainsInput?: string | string[]): boolean {
137+
if (typeof domainsInput === "string" && domainsInput.trim() === "") return true;
138+
if (Array.isArray(domainsInput) && domainsInput.length === 0) return true;
139+
return false;
140+
}
135141
}

test/src/domains.test.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,14 @@ describe("DomainsManager: backward compatibility and domain enabling", () => {
231231
});
232232

233233
describe("parseDomainsInput static method", () => {
234-
it("returns empty array when no input is provided", () => {
234+
it("returns 'all' when no input is provided", () => {
235235
const result = DomainsManager.parseDomainsInput();
236-
expect(result).toEqual([]);
236+
expect(result).toEqual(["all"]);
237237
});
238238

239-
it("returns empty array when undefined is provided", () => {
239+
it("returns 'all' array when undefined is provided", () => {
240240
const result = DomainsManager.parseDomainsInput(undefined);
241-
expect(result).toEqual([]);
241+
expect(result).toEqual(["all"]);
242242
});
243243

244244
it("parses comma-separated string input", () => {
@@ -324,4 +324,24 @@ describe("DomainsManager: backward compatibility and domain enabling", () => {
324324
expect(enabledDomains.size).toBe(9); // Should enable all because 'all' is present
325325
});
326326
});
327+
328+
describe("edge empty string cases for enabling all domains", () => {
329+
it("when an empty array is passed", () => {
330+
const manager = new DomainsManager([]);
331+
const enabledDomains = manager.getEnabledDomains();
332+
expect(enabledDomains.size).toBe(9);
333+
});
334+
335+
it("when a string with only a break line is passed", () => {
336+
const manager = new DomainsManager("\n");
337+
const enabledDomains = manager.getEnabledDomains();
338+
expect(enabledDomains.size).toBe(9);
339+
});
340+
341+
it("when an empty string is passed", () => {
342+
const manager = new DomainsManager("");
343+
const enabledDomains = manager.getEnabledDomains();
344+
expect(enabledDomains.size).toBe(9);
345+
});
346+
});
327347
});

0 commit comments

Comments
 (0)