From f96ecc1845cddee284ede58d1bec4acbbd367275 Mon Sep 17 00:00:00 2001 From: Sergei Zharinov <zharinov@users.noreply.github.com> Date: Wed, 25 Sep 2024 13:03:37 -0300 Subject: [PATCH] refactor(sbt): Remove default parameter from `parseIndexDir` (#31611) --- lib/modules/datasource/sbt-package/index.spec.ts | 13 +++++++++++-- lib/modules/datasource/sbt-package/util.ts | 3 +-- lib/modules/datasource/sbt-plugin/index.spec.ts | 9 +++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/modules/datasource/sbt-package/index.spec.ts b/lib/modules/datasource/sbt-package/index.spec.ts index 05e015d651..620a7958f8 100644 --- a/lib/modules/datasource/sbt-package/index.spec.ts +++ b/lib/modules/datasource/sbt-package/index.spec.ts @@ -1,6 +1,7 @@ import { getPkgReleases } from '..'; import { Fixtures } from '../../../../test/fixtures'; import * as httpMock from '../../../../test/http-mock'; +import { regEx } from '../../../util/regex'; import * as mavenVersioning from '../../versioning/maven'; import { MAVEN_REPO } from '../maven/common'; import { parseIndexDir } from './util'; @@ -8,12 +9,20 @@ import { SbtPackageDatasource } from '.'; describe('modules/datasource/sbt-package/index', () => { it('parses Maven index directory', () => { - expect(parseIndexDir(Fixtures.get(`maven-index.html`))).toMatchSnapshot(); + expect( + parseIndexDir( + Fixtures.get(`maven-index.html`), + (x) => !regEx(/^\.+/).test(x), + ), + ).toMatchSnapshot(); }); it('parses sbt index directory', () => { expect( - parseIndexDir(Fixtures.get(`sbt-plugins-index.html`)), + parseIndexDir( + Fixtures.get(`sbt-plugins-index.html`), + (x) => !regEx(/^\.+/).test(x), + ), ).toMatchSnapshot(); }); diff --git a/lib/modules/datasource/sbt-package/util.ts b/lib/modules/datasource/sbt-package/util.ts index b2d017972e..7b567b7147 100644 --- a/lib/modules/datasource/sbt-package/util.ts +++ b/lib/modules/datasource/sbt-package/util.ts @@ -1,12 +1,11 @@ import { coerceArray } from '../../../util/array'; -import { regEx } from '../../../util/regex'; import { compare } from '../../versioning/maven/compare'; const linkRegExp = /(?<=href=['"])[^'"]*(?=\/['"])/gi; export function parseIndexDir( content: string, - filterFn = (x: string): boolean => !regEx(/^\.+/).test(x), + filterFn: (x: string) => boolean, ): string[] { const unfiltered = coerceArray(content.match(linkRegExp)); return unfiltered.filter(filterFn); diff --git a/lib/modules/datasource/sbt-plugin/index.spec.ts b/lib/modules/datasource/sbt-plugin/index.spec.ts index 6387ff45e6..8b0d53481d 100644 --- a/lib/modules/datasource/sbt-plugin/index.spec.ts +++ b/lib/modules/datasource/sbt-plugin/index.spec.ts @@ -2,6 +2,7 @@ import { codeBlock, html } from 'common-tags'; import { getPkgReleases } from '..'; import { Fixtures } from '../../../../test/fixtures'; import * as httpMock from '../../../../test/http-mock'; +import { regEx } from '../../../util/regex'; import * as mavenVersioning from '../../versioning/maven'; import { MAVEN_REPO } from '../maven/common'; import { parseIndexDir } from '../sbt-package/util'; @@ -12,11 +13,15 @@ const sbtPluginIndex = Fixtures.get(`sbt-plugins-index.html`); describe('modules/datasource/sbt-plugin/index', () => { it('parses Maven index directory', () => { - expect(parseIndexDir(mavenIndexHtml)).toMatchSnapshot(); + expect( + parseIndexDir(mavenIndexHtml, (x) => !regEx(/^\.+/).test(x)), + ).toMatchSnapshot(); }); it('parses sbt index directory', () => { - expect(parseIndexDir(sbtPluginIndex)).toMatchSnapshot(); + expect( + parseIndexDir(sbtPluginIndex, (x) => !regEx(/^\.+/).test(x)), + ).toMatchSnapshot(); }); it('uses proper hostType', () => { -- GitLab