nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: opencomponents/oc
Pull request #1204 (2021-09-02 16:40:46)

sanitise templates and pollinginterval options
pollingInterval according to the wiki is an optional config option with a default of 5 seconds, but it wasn't defaulted, so I'm adding it.
Also I'm sanitising templates to default to empty array, because right now it relies on the fact that lodash method `union` will accept undefined as a parameter (and do a union as if with an empty array), but I think it's safer to have it as empty array from the get-go.


Patch:
diff --git a/src/registry/domain/options-sanitiser.js b/src/registry/domain/options-sanitiser.js
index 465e03ed..9a752d32 100644
--- a/src/registry/domain/options-sanitiser.js
+++ b/src/registry/domain/options-sanitiser.js
@@ -7,7 +7,7 @@ const auth = require('./authentication');
 
 const DEFAULT_NODE_KEEPALIVE_MS = 5000;
 
-module.exports = function(input) {
+module.exports = function (input) {
   const options = _.clone(input);
 
   if (!options.publishAuth) {
@@ -47,6 +47,14 @@ module.exports = function(input) {
     options.discovery = true;
   }
 
+  if (_.isUndefined(options.pollingInterval)) {
+    options.pollingInterval = 5;
+  }
+
+  if (_.isUndefined(options.templates)) {
+    options.templates = [];
+  }
+
   if (
     !_.isUndefined(options.fallbackRegistryUrl) &&
     _.last(options.fallbackRegistryUrl) !== '/'


Test patch:
diff --git a/test/unit/registry-domain-options-sanitiser.js b/test/unit/registry-domain-options-sanitiser.js
index ee751bf9..3f689372 100644
--- a/test/unit/registry-domain-options-sanitiser.js
+++ b/test/unit/registry-domain-options-sanitiser.js
@@ -121,6 +121,38 @@ describe('registry : domain : options-sanitiser', () => {
     });
   });
 
+  describe('when pollingInterval', () => {
+    describe('is provided', () => {
+      const options = { baseUrl: 'dummy', pollingInterval: 10 };
+      it('should not modify it', () => {
+        expect(sanitise(options).pollingInterval).to.deep.equal(10);
+      });
+    });
+
+    describe('is not provided', () => {
+      const options = { baseUrl: 'dummy' };
+      it('should initialize it as 5000', () => {
+        expect(sanitise(options).pollingInterval).to.deep.equal(5);
+      });
+    });
+  });
+
+  describe('when templates', () => {
+    describe('is provided', () => {
+      const options = { baseUrl: 'dummy', templates: [{ name: 'hi' }] };
+      it('should not modify it', () => {
+        expect(sanitise(options).templates).to.deep.equal([{ name: 'hi' }]);
+      });
+    });
+
+    describe('is not provided', () => {
+      const options = { baseUrl: 'dummy' };
+      it('should initialize it as 5000', () => {
+        expect(sanitise(options).templates).to.deep.equal([]);
+      });
+    });
+  });
+
   describe('when env', () => {
     describe('is provided', () => {
       const options = { baseUrl: 'dummy', env: { value: 'test' } };
Repository: gotenberg/gotenberg
Pull request #340 (2021-09-08 22:12:49)

Add supported file extensions for unovonv
Added the following file extensions for unoconv:
- tif
- jpeg
- odp


Patch:
diff --git a/pkg/modules/libreoffice/unoconv/unoconv.go b/pkg/modules/libreoffice/unoconv/unoconv.go
index 9019d28..6385f3a 100644
--- a/pkg/modules/libreoffice/unoconv/unoconv.go
+++ b/pkg/modules/libreoffice/unoconv/unoconv.go
@@ -229,6 +229,7 @@ func (mod Unoconv) Extensions() []string {
 		".fodg",
 		".gif",
 		".jpg",
+		".jpeg",
 		".met",
 		".odd",
 		".otg",
@@ -243,9 +244,11 @@ func (mod Unoconv) Extensions() []string {
 		".swf",
 		".sxd",
 		".sxw",
+		".tif",
 		".tiff",
 		".xhtml",
 		".xpm",
+		".odp",
 		".fodp",
 		".potm",
 		".pot",


Test patch:
diff --git a/pkg/modules/api/middlewares_test.go b/pkg/modules/api/middlewares_test.go
index fc61def..6c4a68c 100644
--- a/pkg/modules/api/middlewares_test.go
+++ b/pkg/modules/api/middlewares_test.go
@@ -111,7 +111,7 @@ func TestHttpErrorHandler(t *testing.T) {
 
 		func() {
 			rand.Seed(time.Now().UnixNano())
-			webhookPort := rand.Intn(65535-1+1) + 1
+			webhookPort := rand.Intn(65535 - 1025 + 1) + 1025
 
 			tc.webhookClient.errorURL = fmt.Sprintf(tc.webhookClient.errorURL, webhookPort)
 
@@ -825,7 +825,7 @@ func TestContextMiddlewareWithWebhook(t *testing.T) {
 			webhook.HidePort = true
 
 			rand.Seed(time.Now().UnixNano())
-			webhookPort := rand.Intn(65535-1+1) + 1
+			webhookPort := rand.Intn(65535 - 1025 + 1) + 1025
 
 			if tc.autoWebhookURLs {
 				c.Request().Header.Set("Gotenberg-Webhook-Url", fmt.Sprintf("http://localhost:%d/", webhookPort))
diff --git a/pkg/modules/libreoffice/unoconv/unoconv_test.go b/pkg/modules/libreoffice/unoconv/unoconv_test.go
index fd589ed..3526f49 100644
--- a/pkg/modules/libreoffice/unoconv/unoconv_test.go
+++ b/pkg/modules/libreoffice/unoconv/unoconv_test.go
@@ -146,7 +146,7 @@ func TestUnoconv_Extensions(t *testing.T) {
 	extensions := mod.Extensions()
 
 	actual := len(extensions)
-	expect := 73
+	expect := 76
 
 	if actual != expect {
 		t.Errorf("expected %d extensions but got %d", expect, actual)
Repository: axios/axios
Pull request #5633 (2023-04-05 16:35:06)

fix(params): re-added the ability to set the function as `paramsSerializer` config;


Patch:
diff --git a/index.d.cts b/index.d.cts
index 0aee7aa..b1c47a3 100644
--- a/index.d.cts
+++ b/index.d.cts
@@ -370,7 +370,7 @@ declare namespace axios {
     transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
     headers?: (RawAxiosRequestHeaders & MethodsHeaders) | AxiosHeaders;
     params?: any;
-    paramsSerializer?: ParamsSerializerOptions;
+    paramsSerializer?: ParamsSerializerOptions | CustomParamsSerializer;
     data?: D;
     timeout?: Milliseconds;
     timeoutErrorMessage?: string;
diff --git a/index.d.ts b/index.d.ts
index be5f182..e9c9f82 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -311,7 +311,7 @@ export interface AxiosRequestConfig<D = any> {
   transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
   headers?: (RawAxiosRequestHeaders & MethodsHeaders) | AxiosHeaders;
   params?: any;
-  paramsSerializer?: ParamsSerializerOptions;
+  paramsSerializer?: ParamsSerializerOptions | CustomParamsSerializer;
   data?: D;
   timeout?: Milliseconds;
   timeoutErrorMessage?: string;
diff --git a/lib/core/Axios.js b/lib/core/Axios.js
index ff602ba..7a6e6f5 100644
--- a/lib/core/Axios.js
+++ b/lib/core/Axios.js
@@ -57,11 +57,17 @@ class Axios {
       }, false);
     }
 
-    if (paramsSerializer !== undefined) {
-      validator.assertOptions(paramsSerializer, {
-        encode: validators.function,
-        serialize: validators.function
-      }, true);
+    if (paramsSerializer != null) {
+      if (utils.isFunction(paramsSerializer)) {
+        config.paramsSerializer = {
+          serialize: paramsSerializer
+        }
+      } else {
+        validator.assertOptions(paramsSerializer, {
+          encode: validators.function,
+          serialize: validators.function
+        }, true);
+      }
     }
 
     // Set config.method


Test patch:
diff --git a/test/unit/adapters/http.js b/test/unit/adapters/http.js
index 5d6620a..769e469 100644
--- a/test/unit/adapters/http.js
+++ b/test/unit/adapters/http.js
@@ -2103,4 +2103,18 @@ describe('supports http with nodejs', function () {
   it('should properly handle synchronous errors inside the adapter', function () {
     return assert.rejects(() => axios.get('http://192.168.0.285'), /Invalid URL/);
   });
+
+  it('should support function as paramsSerializer value', async () => {
+    server = await startHTTPServer((req, res) => res.end(req.url));
+
+    const {data} = await axios.post(LOCAL_SERVER_URL, 'test', {
+      params: {
+        x: 1
+      },
+      paramsSerializer: () => 'foo',
+      maxRedirects: 0
+    });
+
+    assert.strictEqual(data, '/?foo');
+  });
 });
Repository: axios/axios
Pull request #5731 (2023-06-07 02:26:14)

fix(http): remove brackets from hostname
Closes https://github.com/axios/axios/issues/5333

Strips the brackets from hostname fix ipv6 hostname http(s) calls.

 https://github.com/follow-redirects/follow-redirects/blob/d388fe26052a6042310d96964f15f00c56791161/index.js#L549


Rishi556: @DigitalBrainJS Hey, any chance you could take a look at this please? Axios@1.0.0 up to current broke support IPv6 literals. I've had to resort to using 0.27.2 due to this for certain codebases.
ssbarnea: @jasonsaayman @DigitalBrainJS Any chance you could please look at this one, at least approve it to run on CI to see its outcome. Thanks.
Rishi556: @ssbarnea I've published this under six-axios(https://www.npmjs.com/package/six-axios) for now as I need the support while waiting for someone from the team to be able to look at this PR. Hopefully others can find use of it.

Patch:
diff --git a/lib/adapters/http.js b/lib/adapters/http.js
index 366cadc..d465851 100755
--- a/lib/adapters/http.js
+++ b/lib/adapters/http.js
@@ -427,7 +427,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
     if (config.socketPath) {
       options.socketPath = config.socketPath;
     } else {
-      options.hostname = parsed.hostname;
+      options.hostname = parsed.hostname.startsWith("[") ? parsed.hostname.slice(1, -1) : parsed.hostname;
       options.port = parsed.port;
       setProxy(options, config.proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
     }


Test patch:
diff --git a/test/unit/adapters/http.js b/test/unit/adapters/http.js
index d5f70ff..32889ba 100644
--- a/test/unit/adapters/http.js
+++ b/test/unit/adapters/http.js
@@ -159,6 +159,44 @@ describe('supports http with nodejs', function () {
     delete process.env.no_proxy;
   });
 
+  it('should support IPv4 literal strings', function (done) {
+
+    var data = {
+      firstName: 'Fred',
+      lastName: 'Flintstone',
+      emailAddr: 'fred@example.com'
+    };
+
+    server = http.createServer(function (req, res) {
+      res.setHeader('Content-Type', 'application/json');
+      res.end(JSON.stringify(data));
+    }).listen(4444, function () {
+      axios.get('http://127.0.0.1:4444/').then(function (res) {
+        assert.deepEqual(res.data, data);
+        done();
+      }).catch(done);
+    });
+  });
+
+  it('should support IPv6 literal strings', function (done) {
+
+    var data = {
+      firstName: 'Fred',
+      lastName: 'Flintstone',
+      emailAddr: 'fred@example.com'
+    };
+
+    server = http.createServer(function (req, res) {
+      res.setHeader('Content-Type', 'application/json');
+      res.end(JSON.stringify(data));
+    }).listen(4444, function () {
+      axios.get('http://[::1]:4444/').then(function (res) {
+        assert.deepEqual(res.data, data);
+        done();
+      }).catch(done);
+    });
+  });
+
   it('should throw an error if the timeout property is not parsable as a number', function (done) {
 
     server = http.createServer(function (req, res) {
Repository: axios/axios
Pull request #5778 (2023-07-14 11:19:00)

fix: dispatchBeforeRedirect
Patch from: https://github.com/k1de/axios/commit/8b5cab4e318cb7cbecbfecdf0a6ff49b7e3cc70a
Fix: https://github.com/axios/axios/issues/5365

ialexryan: Hi @DigitalBrainJS! Sorry for the direct ping. Could you please consider merging this tiny PR? It fixes a breaking bug (#5365) that is [blocking](https://github.com/axios/axios/issues/6006#issuecomment-1810334234) myself and others from upgrading to 1.x. Thank you! 🙏🏻  

Patch:
diff --git a/index.d.cts b/index.d.cts
index 35a1f0f..d95e6ef 100644
--- a/index.d.cts
+++ b/index.d.cts
@@ -396,7 +396,7 @@ declare namespace axios {
     maxBodyLength?: number;
     maxRedirects?: number;
     maxRate?: number | [MaxUploadRate, MaxDownloadRate];
-    beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>}) => void;
+    beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>, statusCode: HttpStatusCode}) => void;
     socketPath?: string | null;
     transport?: any;
     httpAgent?: any;
diff --git a/index.d.ts b/index.d.ts
index 3a2840b..02a8c09 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -337,7 +337,7 @@ export interface AxiosRequestConfig<D = any> {
   maxBodyLength?: number;
   maxRedirects?: number;
   maxRate?: number | [MaxUploadRate, MaxDownloadRate];
-  beforeRedirect?: (options: Record<string, any>, responseDetails: { headers: Record<string, string> }) => void;
+  beforeRedirect?: (options: Record<string, any>, responseDetails: {headers: Record<string, string>, statusCode: HttpStatusCode}) => void;
   socketPath?: string | null;
   transport?: any;
   httpAgent?: any;
diff --git a/lib/adapters/http.js b/lib/adapters/http.js
index 78255d2..21d6458 100755
--- a/lib/adapters/http.js
+++ b/lib/adapters/http.js
@@ -53,12 +53,12 @@ const supportedProtocols = platform.protocols.map(protocol => {
  *
  * @returns {Object<string, any>}
  */
-function dispatchBeforeRedirect(options) {
+function dispatchBeforeRedirect(options, responseDetails) {
   if (options.beforeRedirects.proxy) {
     options.beforeRedirects.proxy(options);
   }
   if (options.beforeRedirects.config) {
-    options.beforeRedirects.config(options);
+    options.beforeRedirects.config(options, responseDetails);
   }
 }
 


Test patch:
diff --git a/test/unit/adapters/http.js b/test/unit/adapters/http.js
index bbfd093..0af2278 100644
--- a/test/unit/adapters/http.js
+++ b/test/unit/adapters/http.js
@@ -381,8 +381,8 @@ describe('supports http with nodejs', function () {
     }).listen(4444, function () {
       axios.get('http://localhost:4444/', {
         maxRedirects: 3,
-        beforeRedirect: function (options) {
-          if (options.path === '/foo') {
+        beforeRedirect: function (options, responseDetails) {
+          if (options.path === '/foo' && responseDetails.headers.location === '/foo') {
             throw new Error(
               'Provided path is not allowed'
             );
Repository: axios/axios
Pull request #5892 (2023-09-12 11:58:18)

fix(headers): content-encoding header accepts case-insensitive values…
… (#5890)

<!-- Click "Preview" for a more readable version -->

#### Instructions

Please read and follow the instructions before creating and submitting a pull request:

- Create an issue explaining the feature. It could save you some effort in case we don't consider it should be included in axios.
- If you're fixing a bug, try to commit the failing test/s and the code fixing it in different commits.
- Ensure you're following our [contributing guide](https://github.com/axios/axios/blob/master/CONTRIBUTING.md).

**⚠️👆 Delete the instructions before submitting the pull request 👆⚠️**

Describe your pull request here.



Patch:
diff --git a/lib/adapters/http.js b/lib/adapters/http.js
index 888b78d..201252f 100755
--- a/lib/adapters/http.js
+++ b/lib/adapters/http.js
@@ -471,7 +471,7 @@ export default isHttpAdapterSupported && function httpAdapter(config) {
           delete res.headers['content-encoding'];
         }
 
-        switch (res.headers['content-encoding']) {
+        switch ((res.headers['content-encoding'] || '').toLowerCase()) {
         /*eslint default-case:0*/
         case 'gzip':
         case 'x-gzip':


Test patch:
diff --git a/test/unit/adapters/http.js b/test/unit/adapters/http.js
index a588ab8..6e07c77 100644
--- a/test/unit/adapters/http.js
+++ b/test/unit/adapters/http.js
@@ -517,6 +517,7 @@ describe('supports http with nodejs', function () {
 
       for (const [typeName, zipped] of Object.entries({
         gzip: gzip(responseBody),
+        GZIP: gzip(responseBody),
         compress: gzip(responseBody),
         deflate: deflate(responseBody),
         'deflate-raw': deflateRaw(responseBody),
Repository: rackt/react-router
Pull request #2813 (2016-01-01 17:58:27)

Add passing custom histories to match
Will make redux-simple-router integration more clear.


Patch:
diff --git a/modules/match.js b/modules/match.js
index ccf8b8252..332c2f7e6 100644
--- a/modules/match.js
+++ b/modules/match.js
@@ -14,13 +14,13 @@ import { createRouterObject, createRoutingHistory } from './RouterUtils'
  * Note: You probably don't want to use this in a browser. Use
  * the history.listen API instead.
  */
-function match({ routes, location, ...options }, callback) {
+function match({ history, routes, location, ...options }, callback) {
   invariant(
     location,
     'match needs a location'
   )
 
-  let history = createMemoryHistory(options)
+  history = history ? history : createMemoryHistory(options)
   const transitionManager = createTransitionManager(
     history,
     createRoutes(routes)


Test patch:
diff --git a/modules/__tests__/serverRendering-test.js b/modules/__tests__/serverRendering-test.js
index 11475beed..c74a807c3 100644
--- a/modules/__tests__/serverRendering-test.js
+++ b/modules/__tests__/serverRendering-test.js
@@ -1,7 +1,8 @@
-import expect from 'expect'
+import expect, { spyOn } from 'expect'
 import React, { Component } from 'react'
 import { renderToString } from 'react-dom/server'
 import match from '../match'
+import createMemoryHistory from '../createMemoryHistory'
 import RouterContext from '../RouterContext'
 import Link from '../Link'
 
@@ -75,6 +76,21 @@ describe('server rendering', function () {
     })
   })
 
+  it('accepts a custom history', function (done) {
+    const history = createMemoryHistory()
+    const spy = spyOn(history, 'createLocation').andCallThrough()
+
+    match({ history, routes, location: '/dashboard' }, function (error, redirectLocation, renderProps) {
+      const string = renderToString(
+        <RouterContext {...renderProps} />
+      )
+      expect(string).toMatch(/The Dashboard/)
+      expect(spy).toHaveBeenCalled()
+      done()
+    })
+  })
+
+
   it('renders active Links as active', function (done) {
     match({ routes, location: '/about' }, function (error, redirectLocation, renderProps) {
       const string = renderToString(