{"size": 569, "ext": "js", "max_stars_repo_path": "src/buildMessage.js", "max_stars_repo_name": "kevin940726/node-slack-issue-linker", "max_stars_repo_stars_event_min_datetime": "2017-05-14T12:53:54.000Z", "max_stars_repo_stars_event_max_datetime": "2017-05-14T12:53:54.000Z", "max_issues_repo_path": "src/buildMessage.js", "max_issues_repo_name": "kevin940726/node-slack-issue-linker", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/buildMessage.js", "max_forks_repo_name": "kevin940726/node-slack-issue-linker", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.76, "max_line_length": 76, "alphanum_fraction": 0.5430579965}
const {
  OWNER,
  REPO,
  HOST,
} = require('./loadEnv')();

const BASE_URL = HOST === 'github' ? 'https://github.com' : HOST;

const buildMessage = matches => (
  matches
    .map((match) => {
      const owner = match.owner || OWNER;
      const repo = match.repo || REPO;
      const issue = match.issue;

      const url = `${BASE_URL}/${owner}/${repo}/issues/${issue}`;
      const label = `${owner === OWNER ? '' : `${owner}/`}${repo}#${issue}`;

      return `<${url}|${label}> :point_right: _${url}_`;
    })
    .join('\n')
);

module.exports = buildMessage;
