Skip to content

Commit

Permalink
Do not HTML escape URLs etc
Browse files Browse the repository at this point in the history
  • Loading branch information
satterly committed Nov 8, 2021
1 parent a04d9e1 commit f8e613f
Show file tree
Hide file tree
Showing 12 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions .github/slack.yml
Expand Up @@ -7,7 +7,7 @@ title_link: https://support.github.com

text: |
*<{{workflowRunUrl}}|Workflow _{{workflow}}_ job _{{jobName}}_ triggered by _{{eventName}}_ is _{{jobStatus}}_>* for <{{refUrl}}|`{{ref}}`>
{{#if description}}<{{diffUrl}}|`{{diffRef}}`> - {{description}}{{/if}}
{{#if description}}<{{diffUrl}}|`{{diffRef}}`> - {{{description}}}{{/if}}
{{#if payload.commits}}
*Commits*
{{#each payload.commits}}
Expand All @@ -23,7 +23,7 @@ fields:
value: "{{#each jobSteps}}{{icon this.outcome}} {{@key}}\n{{/each}}"
short: false
- title: Workflow
value: "<{{workflowUrl}}|{{workflow}}>"
value: "<{{{workflowUrl}}}|{{workflow}}>"
short: true
- title: Git Ref
value: "{{ref}} ({{refType}})"
Expand Down
2 changes: 1 addition & 1 deletion __tests__/config.test.ts
Expand Up @@ -128,7 +128,7 @@ test('custom config of slack action', async () => {
{
short: true,
title: 'Workflow',
value: '<https://github.com/act10ns/slack/actions?query&#x3D;build-test|build-test>'
value: '<https://github.com/act10ns/slack/actions?query=build-test|build-test>'
},
{
short: true,
Expand Down
4 changes: 2 additions & 2 deletions __tests__/fixtures/slack.yml
Expand Up @@ -7,7 +7,7 @@ title_link: https://support.github.com

text: |
*<{{workflowRunUrl}}|Workflow _{{workflow}}_ job _{{jobName}}_ triggered by _{{eventName}}_ is _{{jobStatus}}_>* for <{{refUrl}}|`{{ref}}`>
{{#if description}}<{{diffUrl}}|`{{diffRef}}`> - {{description}}{{/if}}
{{#if description}}<{{diffUrl}}|`{{diffRef}}`> - {{{description}}}{{/if}}
{{#if payload.commits}}
*Commits*
{{#each payload.commits}}
Expand All @@ -23,7 +23,7 @@ fields:
value: "{{#each jobSteps}}{{icon this.outcome}} {{@key}}\n{{/each}}"
short: false
- title: Workflow
value: "<{{workflowUrl}}|{{workflow}}>"
value: "<{{{workflowUrl}}}|{{workflow}}>"
short: true
- title: Git Ref
value: "{{ref}} ({{refType}})"
Expand Down
2 changes: 1 addition & 1 deletion __tests__/inputs.test.ts
Expand Up @@ -121,7 +121,7 @@ test('custom config of slack action', async () => {
{
short: true,
title: 'Workflow',
value: '<https://github.com/act10ns/slack/actions?query&#x3D;build-test|build-test>'
value: '<https://github.com/act10ns/slack/actions?query=build-test|build-test>'
},
{
short: true,
Expand Down
2 changes: 1 addition & 1 deletion __tests__/job_status.test.ts
Expand Up @@ -103,7 +103,7 @@ test('push event to slack', async () => {
mrkdwn_in: ['pretext', 'text', 'fields'],
pretext: '',
text:
'*<https://github.com/act10ns/slack/actions?query&#x3D;build-test|Workflow _build-test_ job _CI Tests_ triggered by _push_ is _failure_>* for <https://github.com/act10ns/slack/commits/master|`master`>\n<https://github.com/act10ns/slack/compare/db9fe60430a6...68d48876e079|`68d48876`> - 4 commits',
'*<https://github.com/act10ns/slack/actions?query=build-test|Workflow _build-test_ job _CI Tests_ triggered by _push_ is _failure_>* for <https://github.com/act10ns/slack/commits/master|`master`>\n<https://github.com/act10ns/slack/compare/db9fe60430a6...68d48876e079|`68d48876`> - 4 commits',
title: '',
fields: [
{
Expand Down
2 changes: 1 addition & 1 deletion __tests__/pull_request.test.ts
Expand Up @@ -70,7 +70,7 @@ test('pull request event to slack', async () => {
mrkdwn_in: ['pretext', 'text', 'fields'],
pretext: '',
text:
'*<https://github.com/act10ns/slack/actions?query&#x3D;build-test|Workflow _build-test_ job _Build and Test_ triggered by _pull_request_ is _Success_>* for <https://github.com/act10ns/slack/pull/17|`#17`>\n<https://github.com/act10ns/slack/pull/17/files|`rename-to-slack`> - Rename to slack',
'*<https://github.com/act10ns/slack/actions?query=build-test|Workflow _build-test_ job _Build and Test_ triggered by _pull_request_ is _Success_>* for <https://github.com/act10ns/slack/pull/17|`#17`>\n<https://github.com/act10ns/slack/pull/17/files|`rename-to-slack`> - Rename to slack',
title: '',
fields: [],
footer: '<https://github.com/act10ns/slack|act10ns/slack> #760',
Expand Down
2 changes: 1 addition & 1 deletion __tests__/push.test.ts
Expand Up @@ -70,7 +70,7 @@ test('push event to slack', async () => {
mrkdwn_in: ['pretext', 'text', 'fields'],
pretext: '',
text:
'*<https://github.com/act10ns/slack/actions?query&#x3D;build-test|Workflow _build-test_ job _Build and Test_ triggered by _push_ is _Success_>* for <https://github.com/act10ns/slack/commits/master|`master`>\n<https://github.com/act10ns/slack/compare/db9fe60430a6...68d48876e079|`68d48876`> - 4 commits',
'*<https://github.com/act10ns/slack/actions?query=build-test|Workflow _build-test_ job _Build and Test_ triggered by _push_ is _Success_>* for <https://github.com/act10ns/slack/commits/master|`master`>\n<https://github.com/act10ns/slack/compare/db9fe60430a6...68d48876e079|`68d48876`> - 4 commits',
title: '',
fields: [],
footer: '<https://github.com/act10ns/slack|act10ns/slack> #8',
Expand Down
2 changes: 1 addition & 1 deletion __tests__/release.test.ts
Expand Up @@ -73,7 +73,7 @@ test('release event to slack', async () => {
mrkdwn_in: ['pretext', 'text', 'fields'],
pretext: '',
text:
'*<https://github.com/act10ns/slack/actions?query&#x3D;build-test|Workflow _build-test_ job _Build and Test_ triggered by _release_ is _Success_>* for <https://github.com/act10ns/slack/commits/refs/tags/v1.0.13|`refs/tags/v1.0.13`>\n',
'*<https://github.com/act10ns/slack/actions?query=build-test|Workflow _build-test_ job _Build and Test_ triggered by _release_ is _Success_>* for <https://github.com/act10ns/slack/commits/refs/tags/v1.0.13|`refs/tags/v1.0.13`>\n',
title: '',
fields: [],
footer: '<https://github.com/act10ns/slack|act10ns/slack> #817',
Expand Down
2 changes: 1 addition & 1 deletion __tests__/schedule.test.ts
Expand Up @@ -66,7 +66,7 @@ test('schedule event to slack', async () => {
mrkdwn_in: ['pretext', 'text', 'fields'],
pretext: '',
text:
'*<https://github.com/act10ns/slack/actions?query&#x3D;schedule-test|Workflow _schedule-test_ job _Build and Test_ triggered by _schedule_ is _Success_>* for <https://github.com/act10ns/slack/commits/master|`master`>\n<https://github.com/act10ns/slack/commit/09a6b2c9|`09a6b2c9`> - Schedule &#x60;*/15 * * * *&#x60;',
'*<https://github.com/act10ns/slack/actions?query=schedule-test|Workflow _schedule-test_ job _Build and Test_ triggered by _schedule_ is _Success_>* for <https://github.com/act10ns/slack/commits/master|`master`>\n<https://github.com/act10ns/slack/commit/09a6b2c9|`09a6b2c9`> - Schedule `*/15 * * * *`',
title: '',
fields: [],
footer: '<https://github.com/act10ns/slack|act10ns/slack> #179',
Expand Down
2 changes: 1 addition & 1 deletion __tests__/workflow_dispatch.test.ts
Expand Up @@ -71,7 +71,7 @@ test('workflow_dispatch event to slack', async () => {
mrkdwn_in: ['pretext', 'text', 'fields'],
pretext: '',
text:
'*<https://github.com/act10ns/slack/actions?query&#x3D;manual-test|Workflow _manual-test_ job _Build and Test_ triggered by _workflow_dispatch_ is _Success_>* for <https://github.com/act10ns/slack/commits/master|`master`>\n',
'*<https://github.com/act10ns/slack/actions?query=manual-test|Workflow _manual-test_ job _Build and Test_ triggered by _workflow_dispatch_ is _Success_>* for <https://github.com/act10ns/slack/commits/master|`master`>\n',
title: '',
fields: [],
footer: '<https://github.com/act10ns/slack|act10ns/slack> #6',
Expand Down
4 changes: 2 additions & 2 deletions dist/index.js
Expand Up @@ -13387,9 +13387,9 @@ function send(url, jobName, jobStatus, jobSteps, channel, message, opts) {
});
const pretextTemplate = handlebars_1.default.compile((opts === null || opts === void 0 ? void 0 : opts.pretext) || '');
const titleTemplate = handlebars_1.default.compile((opts === null || opts === void 0 ? void 0 : opts.title) || '');
const defaultText = `${'*<{{workflowUrl}}|Workflow _{{workflow}}_ ' +
const defaultText = `${'*<{{{workflowUrl}}}|Workflow _{{workflow}}_ ' +
'job _{{jobName}}_ triggered by _{{eventName}}_ is _{{jobStatus}}_>* ' +
'for <{{refUrl}}|`{{ref}}`>\n'}${description ? '<{{diffUrl}}|`{{diffRef}}`> - {{description}}' : ''}`;
'for <{{refUrl}}|`{{ref}}`>\n'}${description ? '<{{diffUrl}}|`{{diffRef}}`> - {{{description}}}' : ''}`;
const textTemplate = handlebars_1.default.compile(message || (opts === null || opts === void 0 ? void 0 : opts.text) || defaultText);
const defaultFallback = `[GitHub]: [{{repositoryName}}] {{workflow}} {{eventName}} ${action ? '{{action}} ' : ''}{{jobStatus}}`;
const fallbackTemplate = handlebars_1.default.compile((opts === null || opts === void 0 ? void 0 : opts.fallback) || defaultFallback);
Expand Down
4 changes: 2 additions & 2 deletions src/slack.ts
Expand Up @@ -171,10 +171,10 @@ export async function send(
const titleTemplate = Handlebars.compile(opts?.title || '')

const defaultText = `${
'*<{{workflowUrl}}|Workflow _{{workflow}}_ ' +
'*<{{{workflowUrl}}}|Workflow _{{workflow}}_ ' +
'job _{{jobName}}_ triggered by _{{eventName}}_ is _{{jobStatus}}_>* ' +
'for <{{refUrl}}|`{{ref}}`>\n'
}${description ? '<{{diffUrl}}|`{{diffRef}}`> - {{description}}' : ''}`
}${description ? '<{{diffUrl}}|`{{diffRef}}`> - {{{description}}}' : ''}`
const textTemplate = Handlebars.compile(message || opts?.text || defaultText)

const defaultFallback = `[GitHub]: [{{repositoryName}}] {{workflow}} {{eventName}} ${
Expand Down

0 comments on commit f8e613f

Please sign in to comment.