From ded7dafd72f0a62fda7fbb5af329b74aff268630 Mon Sep 17 00:00:00 2001 From: jNullj <15849761+jNullj@users.noreply.github.com> Date: Sat, 25 Apr 2026 21:54:37 +0300 Subject: [PATCH 1/3] refactor: replace route format with pattern for [travis] part of issue #3329 helps unblock #11800 Co-authored-by: Copilot --- services/travis/travis-build.service.js | 15 +++++++++------ services/travis/travis-build.tester.js | 4 ++++ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/services/travis/travis-build.service.js b/services/travis/travis-build.service.js index eb18f228fb433..58c9adc6a4585 100644 --- a/services/travis/travis-build.service.js +++ b/services/travis/travis-build.service.js @@ -1,6 +1,6 @@ import Joi from 'joi' import { isBuildStatus, renderBuildStatusBadge } from '../build-status.js' -import { BaseSvgScrapingService, pathParams } from '../index.js' +import { BaseSvgScrapingService, pathParams, NotFound } from '../index.js' const schema = Joi.object({ message: Joi.alternatives() @@ -12,9 +12,8 @@ export class TravisComBuild extends BaseSvgScrapingService { static category = 'build' static route = { - base: 'travis', - format: 'com/(?!php-v)([^/]+/[^/]+?)(?:/(.+?))?', - capture: ['userRepo', 'branch'], + base: 'travis/com', + pattern: ':user/:repo/:branch*', } static openApi = { @@ -62,10 +61,14 @@ export class TravisComBuild extends BaseSvgScrapingService { return renderBuildStatusBadge({ status }) } - async handle({ userRepo, branch }) { + async handle({ user, repo, branch }) { + if (user.startsWith('php-v')) { + throw new NotFound({ prettyMessage: 'not found' }) + } + const { message: status } = await this._requestSvg({ schema, - url: `https://api.travis-ci.com/${userRepo}.svg`, + url: `https://api.travis-ci.com/${user}/${repo}.svg`, options: { searchParams: { branch } }, valueMatcher: />([^<>]+)<\/text><\/g>/, }) diff --git a/services/travis/travis-build.tester.js b/services/travis/travis-build.tester.js index faf301095de4c..63aea3a57ee88 100644 --- a/services/travis/travis-build.tester.js +++ b/services/travis/travis-build.tester.js @@ -27,3 +27,7 @@ t.create('invalid svg response') nock('https://api.travis-ci.com').get('/foo/bar.svg').reply(200), ) .expectBadge({ label: 'build', message: 'unparseable svg response' }) + +t.create('php-v user is rejected') + .get('/com/php-v-starting/some-repo.json') + .expectBadge({ label: 'build', message: 'not found' }) From 69134d1c007d5d95e1685766b673a83201c72885 Mon Sep 17 00:00:00 2001 From: jNullj <15849761+jNullj@users.noreply.github.com> Date: Sat, 25 Apr 2026 21:59:52 +0300 Subject: [PATCH 2/3] fix: remove redundant '/com' prefix from Travis tests --- services/travis/travis-build.tester.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/services/travis/travis-build.tester.js b/services/travis/travis-build.tester.js index 63aea3a57ee88..2cc52263e60b1 100644 --- a/services/travis/travis-build.tester.js +++ b/services/travis/travis-build.tester.js @@ -4,30 +4,30 @@ import { createServiceTester } from '../tester.js' export const t = await createServiceTester() t.create('build status on default branch') - .get('/com/ivandelabeldad/rackian-gateway.json') + .get('/ivandelabeldad/rackian-gateway.json') .expectBadge({ label: 'build', message: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')), }) t.create('build status on named branch') - .get('/com/ivandelabeldad/rackian-gateway.json') + .get('/ivandelabeldad/rackian-gateway.json') .expectBadge({ label: 'build', message: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')), }) t.create('unknown repo') - .get('/com/this-repo/does-not-exist.json') + .get('/this-repo/does-not-exist.json') .expectBadge({ label: 'build', message: 'unknown' }) t.create('invalid svg response') - .get('/com/foo/bar.json') + .get('/foo/bar.json') .intercept(nock => nock('https://api.travis-ci.com').get('/foo/bar.svg').reply(200), ) .expectBadge({ label: 'build', message: 'unparseable svg response' }) t.create('php-v user is rejected') - .get('/com/php-v-starting/some-repo.json') + .get('/php-v-starting/some-repo.json') .expectBadge({ label: 'build', message: 'not found' }) From 4a722970d8eb17a05f48eefbf9dd4b6f374e5fb7 Mon Sep 17 00:00:00 2001 From: jNullj <15849761+jNullj@users.noreply.github.com> Date: Tue, 5 May 2026 22:48:03 +0300 Subject: [PATCH 3/3] remove php-v route exclusion --- services/travis/travis-build.service.js | 6 +----- services/travis/travis-build.tester.js | 4 ---- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/services/travis/travis-build.service.js b/services/travis/travis-build.service.js index 58c9adc6a4585..b1f324e9c2f44 100644 --- a/services/travis/travis-build.service.js +++ b/services/travis/travis-build.service.js @@ -1,6 +1,6 @@ import Joi from 'joi' import { isBuildStatus, renderBuildStatusBadge } from '../build-status.js' -import { BaseSvgScrapingService, pathParams, NotFound } from '../index.js' +import { BaseSvgScrapingService, pathParams } from '../index.js' const schema = Joi.object({ message: Joi.alternatives() @@ -62,10 +62,6 @@ export class TravisComBuild extends BaseSvgScrapingService { } async handle({ user, repo, branch }) { - if (user.startsWith('php-v')) { - throw new NotFound({ prettyMessage: 'not found' }) - } - const { message: status } = await this._requestSvg({ schema, url: `https://api.travis-ci.com/${user}/${repo}.svg`, diff --git a/services/travis/travis-build.tester.js b/services/travis/travis-build.tester.js index 2cc52263e60b1..23fbc8e636b97 100644 --- a/services/travis/travis-build.tester.js +++ b/services/travis/travis-build.tester.js @@ -27,7 +27,3 @@ t.create('invalid svg response') nock('https://api.travis-ci.com').get('/foo/bar.svg').reply(200), ) .expectBadge({ label: 'build', message: 'unparseable svg response' }) - -t.create('php-v user is rejected') - .get('/php-v-starting/some-repo.json') - .expectBadge({ label: 'build', message: 'not found' })