Skip to content

Commit e89cc5a

Browse files
jNulljCopilot
andauthored
refactor: replace route format with pattern for [Travis] (#11813)
* refactor: replace route format with pattern for [travis] part of issue #3329 helps unblock #11800 Co-authored-by: Copilot <copilot@github.com> * fix: remove redundant '/com' prefix from Travis tests * remove php-v route exclusion --------- Co-authored-by: Copilot <copilot@github.com>
1 parent 7c7c28f commit e89cc5a

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

services/travis/travis-build.service.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ export class TravisComBuild extends BaseSvgScrapingService {
1212
static category = 'build'
1313

1414
static route = {
15-
base: 'travis',
16-
format: 'com/(?!php-v)([^/]+/[^/]+?)(?:/(.+?))?',
17-
capture: ['userRepo', 'branch'],
15+
base: 'travis/com',
16+
pattern: ':user/:repo/:branch*',
1817
}
1918

2019
static openApi = {
@@ -62,10 +61,10 @@ export class TravisComBuild extends BaseSvgScrapingService {
6261
return renderBuildStatusBadge({ status })
6362
}
6463

65-
async handle({ userRepo, branch }) {
64+
async handle({ user, repo, branch }) {
6665
const { message: status } = await this._requestSvg({
6766
schema,
68-
url: `https://api.travis-ci.com/${userRepo}.svg`,
67+
url: `https://api.travis-ci.com/${user}/${repo}.svg`,
6968
options: { searchParams: { branch } },
7069
valueMatcher: />([^<>]+)<\/text><\/g>/,
7170
})

services/travis/travis-build.tester.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ import { createServiceTester } from '../tester.js'
44
export const t = await createServiceTester()
55

66
t.create('build status on default branch')
7-
.get('/com/ivandelabeldad/rackian-gateway.json')
7+
.get('/ivandelabeldad/rackian-gateway.json')
88
.expectBadge({
99
label: 'build',
1010
message: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')),
1111
})
1212

1313
t.create('build status on named branch')
14-
.get('/com/ivandelabeldad/rackian-gateway.json')
14+
.get('/ivandelabeldad/rackian-gateway.json')
1515
.expectBadge({
1616
label: 'build',
1717
message: Joi.alternatives().try(isBuildStatus, Joi.equal('unknown')),
1818
})
1919

2020
t.create('unknown repo')
21-
.get('/com/this-repo/does-not-exist.json')
21+
.get('/this-repo/does-not-exist.json')
2222
.expectBadge({ label: 'build', message: 'unknown' })
2323

2424
t.create('invalid svg response')
25-
.get('/com/foo/bar.json')
25+
.get('/foo/bar.json')
2626
.intercept(nock =>
2727
nock('https://api.travis-ci.com').get('/foo/bar.svg').reply(200),
2828
)

0 commit comments

Comments
 (0)