nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: oliverschwendener/ueli
Pull request #1147 (2024-07-28 06:32:11)

fix: Use "kl" instead of "lk" as DuckDuckGo parameter
DuckDuckGo's region parameter is supposed to be “kl”. 🧐
cf: https://duckduckgo.com/duckduckgo-help-pages/settings/params/


oliverschwendener: True, thanks alot!
ykhrito: Sorry, I signed the commit and pushed it again! 🙇

Patch:
diff --git a/src/main/Extensions/WebSearch/DuckDuckGoWebSearchEngine.ts b/src/main/Extensions/WebSearch/DuckDuckGoWebSearchEngine.ts
index b4314b9a..8ae1e6c2 100644
--- a/src/main/Extensions/WebSearch/DuckDuckGoWebSearchEngine.ts
+++ b/src/main/Extensions/WebSearch/DuckDuckGoWebSearchEngine.ts
@@ -25,7 +25,7 @@ export class DuckDuckGoWebSearchEngine implements WebSearchEngine {
     }
 
     public getSearchUrl(searchTerm: string, locale: string): string {
-        return `https://duckduckgo.com/?q=${encodeURIComponent(searchTerm)}&lk=${this.getLocaleString(locale)}`;
+        return `https://duckduckgo.com/?q=${encodeURIComponent(searchTerm)}&kl=${this.getLocaleString(locale)}`;
     }
 
     public getImageFileName(): string {


Test patch:
diff --git a/src/main/Extensions/WebSearch/DuckDuckGoWebSearchEngine.test.ts b/src/main/Extensions/WebSearch/DuckDuckGoWebSearchEngine.test.ts
index 40395aa2..66df52bd 100644
--- a/src/main/Extensions/WebSearch/DuckDuckGoWebSearchEngine.test.ts
+++ b/src/main/Extensions/WebSearch/DuckDuckGoWebSearchEngine.test.ts
@@ -12,8 +12,8 @@ describe(DuckDuckGoWebSearchEngine, () => {
             const net = <Net>{ fetch: (url) => fetchMock(url) };
 
             expect(await new DuckDuckGoWebSearchEngine(net).getSuggestions("test", "en-US")).toEqual([
-                { text: "test1", url: "https://duckduckgo.com/?q=test1&lk=us-en" },
-                { text: "test2", url: "https://duckduckgo.com/?q=test2&lk=us-en" },
+                { text: "test1", url: "https://duckduckgo.com/?q=test1&kl=us-en" },
+                { text: "test2", url: "https://duckduckgo.com/?q=test2&kl=us-en" },
             ]);
         });
     });
@@ -21,13 +21,13 @@ describe(DuckDuckGoWebSearchEngine, () => {
     describe(DuckDuckGoWebSearchEngine.prototype.getSearchUrl, () => {
         it("should return the search URL", () => {
             expect(new DuckDuckGoWebSearchEngine(<Net>{}).getSearchUrl("test", "en-US")).toBe(
-                "https://duckduckgo.com/?q=test&lk=us-en",
+                "https://duckduckgo.com/?q=test&kl=us-en",
             );
         });
 
         it("should return the search URL with default language when the given locale is not supported", () => {
             expect(new DuckDuckGoWebSearchEngine(<Net>{}).getSearchUrl("test", "de-DE")).toBe(
-                "https://duckduckgo.com/?q=test&lk=us-en",
+                "https://duckduckgo.com/?q=test&kl=us-en",
             );
         });
     });
Repository: oliverschwendener/ueli
Pull request #1169 (2024-08-16 22:58:34)

fix(IniFileParser): Fixed error handling
Fixed error handling and added test to ensure errors are thrown when appropriate


Patch:
diff --git a/src/main/Core/IniFileParser/IniFileParser.ts b/src/main/Core/IniFileParser/IniFileParser.ts
index 83c2f8a7..85e62a9a 100644
--- a/src/main/Core/IniFileParser/IniFileParser.ts
+++ b/src/main/Core/IniFileParser/IniFileParser.ts
@@ -26,11 +26,12 @@ export class IniFileParser implements IniFileParserInterface {
         for (const line of fileLines) {
             // New group
             if (line.startsWith("[") && line.endsWith("]") && !line.slice(1, -1).match(/\[\]/m)) {
-                if (result[line]) {
-                    throw `Ini Format Error! Duplicate groups found in ${fileString}`;
+                group = line.slice(1, -1);
+
+                if (result[group]) {
+                    throw new Error(`Ini Format Error. Duplicate group ${group} found`);
                 }
 
-                group = line.slice(1, -1);
                 result[group] = {};
             } else {
                 // Entry
@@ -38,7 +39,7 @@ export class IniFileParser implements IniFileParserInterface {
                 const entry = entrySplit.join("=");
 
                 if (result[group][key]) {
-                    throw `Ini Format Error! Duplicate key in ${group} in file ${fileString}`;
+                    throw Error(`Ini Format Error. Duplicate key ${key} in ${group}`);
                 }
 
                 result[group][key] = entry;


Test patch:
diff --git a/src/main/Core/IniFileParser/IniFileParser.test.ts b/src/main/Core/IniFileParser/IniFileParser.test.ts
index 5a1b9fb9..5186e9c7 100644
--- a/src/main/Core/IniFileParser/IniFileParser.test.ts
+++ b/src/main/Core/IniFileParser/IniFileParser.test.ts
@@ -88,4 +88,41 @@ datadir = /var/lib/data
             },
         });
     });
+
+    it("should throw an error on duplicate group entries", () => {
+        const iniFileString = `
+; This comment is being ignored
+scope = global
+comments = no;inline;comments
+
+[database]
+user = dbuser
+password = dbpassword
+database = use_this_database
+
+[database]
+datadir = /var/lib/data
+                `;
+
+        expect(() => new IniFileParser().parseIniFileContent(iniFileString.trim())).toThrowError();
+    });
+
+    it("should throw an error on duplicate key entries", () => {
+        const iniFileString = `
+; This comment is being ignored
+scope = global
+comments = no;inline;comments
+
+[database]
+user = dbuser
+password = dbpassword
+database = use_this_database
+user = notdbuser
+
+[paths.default]
+datadir = /var/lib/data
+                `;
+
+        expect(() => new IniFileParser().parseIniFileContent(iniFileString.trim())).toThrowError();
+    });
 });
Repository: oliverschwendener/ueli
Pull request #1176 (2024-08-26 08:45:31)

fix: Use "utf8" encoding for Buffer on Base64 conversion
Encoding specified for Buffer on Base64 Conversion should be “utf8”, not “binary”.
This causes that non-ASCII characters, Emoji, etc... are not encoded/decoded correctly.

For example: "thumbs-up"👍should be encoded as "8J+RjQ=="

```shell
# using coreutils on Linux shell
$ printf 👍 | base64
8J+RjQ==
```

but Base64 Conversion result:
![image](https://github.com/user-attachments/assets/5d4e8755-b0b6-4a8e-aa7b-e197a1b8201b)

This PR fix would make the following result:
![image](https://github.com/user-attachments/assets/002289e7-9932-4ed3-a05e-ee80a08fa05c)

oliverschwendener: @ChristopherSteiner 
oliverschwendener: @ykhrito Please add a test case for this.
ykhrito: I've added test cases, please check it out.
oliverschwendener: @ChristopherSteiner If this is good for you, I'll merge it.
ChristopherSteiner: Yes looks good! Go ahead please 

Patch:
diff --git a/src/main/Extensions/Base64Conversion/Base64Converter.ts b/src/main/Extensions/Base64Conversion/Base64Converter.ts
index 944be2d2..71e2ac60 100644
--- a/src/main/Extensions/Base64Conversion/Base64Converter.ts
+++ b/src/main/Extensions/Base64Conversion/Base64Converter.ts
@@ -2,10 +2,10 @@ import { Buffer } from "buffer";
 
 export class Base64Converter {
     public static encode(payload: string): string {
-        return Buffer.from(payload, "binary").toString("base64");
+        return Buffer.from(payload, "utf8").toString("base64");
     }
 
     public static decode(payload: string): string {
-        return Buffer.from(payload, "base64").toString("binary");
+        return Buffer.from(payload, "base64").toString("utf8");
     }
 }


Test patch:
diff --git a/src/main/Extensions/Base64Conversion/Base64Converter.test.ts b/src/main/Extensions/Base64Conversion/Base64Converter.test.ts
index 9278c6c1..85287105 100644
--- a/src/main/Extensions/Base64Conversion/Base64Converter.test.ts
+++ b/src/main/Extensions/Base64Conversion/Base64Converter.test.ts
@@ -6,11 +6,19 @@ describe(Base64Converter, () => {
         it("should return the correct base64 encoded value of a string", () => {
             expect(Base64Converter.encode("Test:1886")).toBe("VGVzdDoxODg2");
         });
+
+        it("should return the correct base64 encoded value of a string containing non-ASCII characters", () => {
+            expect(Base64Converter.encode("Zürich ist schön.")).toBe("WsO8cmljaCBpc3Qgc2Now7ZuLg==");
+        });
     });
 
     describe(Base64Converter.decode, () => {
         it("should return the correct decoded value of a base64 string", () => {
             expect(Base64Converter.decode("VGhpcyBpcyBhIHRlc3Qh")).toBe("This is a test!");
         });
+
+        it("should return the correct decoded value of a base64 string containing non-ASCII characters", () => {
+            expect(Base64Converter.decode("4pyF8J+RjQ==")).toBe("✅👍");
+        });
     });
 });
Repository: oliverschwendener/ueli
Pull request #1227 (2024-10-03 07:11:17)

fix(WindowsApplicationIconExtractor): ignore case of file extension
Title says it all.

Fixes potentially #1133


Patch:
diff --git a/src/main/Core/ImageGenerator/Windows/WindowsApplicationIconExtractor.ts b/src/main/Core/ImageGenerator/Windows/WindowsApplicationIconExtractor.ts
index a707b075..7d775440 100644
--- a/src/main/Core/ImageGenerator/Windows/WindowsApplicationIconExtractor.ts
+++ b/src/main/Core/ImageGenerator/Windows/WindowsApplicationIconExtractor.ts
@@ -15,11 +15,8 @@ export class WindowsApplicationIconExtractor implements FileIconExtractor {
     ) {}
 
     public matchesFilePath(filePath: string) {
-        return (
-            filePath.endsWith(".lnk") ||
-            filePath.endsWith(".url") ||
-            filePath.endsWith(".appref-ms") ||
-            filePath.endsWith(".exe")
+        return [".lnk", ".url", ".appref-ms", ".exe"].some((fileExtension) =>
+            filePath.toLowerCase().endsWith(fileExtension),
         );
     }
 


Test patch:
diff --git a/src/main/Core/ImageGenerator/Windows/WindowsApplicationIconExtractor.test.ts b/src/main/Core/ImageGenerator/Windows/WindowsApplicationIconExtractor.test.ts
new file mode 100644
index 00000000..fb1e3f0b
--- /dev/null
+++ b/src/main/Core/ImageGenerator/Windows/WindowsApplicationIconExtractor.test.ts
@@ -0,0 +1,48 @@
+import { describe, expect, it } from "vitest";
+import { WindowsApplicationIconExtractor } from "./WindowsApplicationIconExtractor";
+
+describe(WindowsApplicationIconExtractor, () => {
+    describe(WindowsApplicationIconExtractor.prototype.matchesFilePath, () => {
+        const testMatchesFilePath = ({ filePath, expected }: { filePath: string; expected: boolean }) =>
+            expect(new WindowsApplicationIconExtractor(null, null, null, "").matchesFilePath(filePath)).toBe(expected);
+
+        it("should return true when file path ends with .lnk, .url, .appref-ms, .exe", () => {
+            const filePaths = [
+                "file.lnk",
+                "file.url",
+                "file.appref-ms",
+                "file.exe",
+                "file.LNK",
+                "file.URL",
+                "file.APPREF-MS",
+                "file.EXE",
+            ];
+
+            for (const filePath of filePaths) {
+                testMatchesFilePath({ filePath, expected: true });
+            }
+        });
+
+        it("should return false when file path ends with other file extensions", () => {
+            const filePaths = [
+                "",
+                " ",
+                "file",
+                "file.ln",
+                "file.ex",
+                "lnk",
+                "exe",
+                "file.txt",
+                "file.doc",
+                "file.docx",
+                "file.pdf",
+                "file.jpg",
+                "file.png",
+            ];
+
+            for (const filePath of filePaths) {
+                testMatchesFilePath({ filePath, expected: false });
+            }
+        });
+    });
+});
Repository: skx/monkey
Pull request #74 (2021-01-06 14:34:38)

Rather than treating the shebang as special make '#' a comment
This is more consistent.


Patch:
diff --git a/lexer/lexer.go b/lexer/lexer.go
index 090df35..5f3e5b1 100644
--- a/lexer/lexer.go
+++ b/lexer/lexer.go
@@ -69,13 +69,8 @@ func (l *Lexer) NextToken() token.Token {
 	l.skipWhitespace()
 
 	// skip single-line comments
-	if l.ch == rune('/') && l.peekChar() == rune('/') {
-		l.skipComment()
-		return (l.NextToken())
-	}
-
-	// skip shebang
-	if l.ch == rune('#') && l.peekChar() == rune('!') && l.position == 0 {
+	if l.ch == rune('#') ||
+		(l.ch == rune('/') && l.peekChar() == rune('/')) {
 		l.skipComment()
 		return (l.NextToken())
 	}


Test patch:
diff --git a/lexer/lexer_test.go b/lexer/lexer_test.go
index d274418..b549c2b 100644
--- a/lexer/lexer_test.go
+++ b/lexer/lexer_test.go
@@ -203,7 +203,8 @@ func TestUnicodeLexer(t *testing.T) {
 func TestSimpleComment(t *testing.T) {
 	input := `=+// This is a comment
 // This is still a comment
-let a = 1;
+# I like comments
+let a = 1; # This is a comment too.
 // This is a final
 // comment on two-lines`