Skip to content

Commit

Permalink
don't URL encode slash in [githubactionsworkflow] badge
Browse files Browse the repository at this point in the history
  • Loading branch information
chris48s committed Jun 26, 2023
1 parent 53efe52 commit 61491f9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
8 changes: 5 additions & 3 deletions services/github/github-actions-workflow-status.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,13 @@ export default class GithubActionsWorkflowStatus extends BaseSvgScrapingService
}

async fetch({ user, repo, workflow, branch, event }) {
const workflowPath = workflow
.split('/')
.map(el => encodeURIComponent(el))
.join('/')
const { message: status } = await this._requestSvg({
schema,
url: `https://github.com/${user}/${repo}/actions/workflows/${encodeURIComponent(
workflow
)}/badge.svg`,
url: `https://github.com/${user}/${repo}/actions/workflows/${workflowPath}/badge.svg`,
options: { searchParams: { branch, event } },
valueMatcher: />([^<>]+)<\/tspan><\/text><\/g><path/,
httpErrors: {
Expand Down
14 changes: 14 additions & 0 deletions services/github/github-actions-workflow-status.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,17 @@ t.create('valid workflow (with event)')
label: 'build',
message: isWorkflowStatus,
})

t.create('valid workflow with / in workflow name')
.get('/chris48s/blogmarks/pages/pages-build-deployment.json')
.expectBadge({
label: 'build',
message: isWorkflowStatus,
})

t.create('valid workflow with special chars in workflow name')
.get('/chris48s/test-workflows/special%3A%26chars.yml.json')
.expectBadge({
label: 'build',
message: isWorkflowStatus,
})

0 comments on commit 61491f9

Please sign in to comment.