Skip to content

Commit

Permalink
Merge pull request #66 from Gawdl3y/feat/release-notes-usernames
Browse files Browse the repository at this point in the history
Link GitHub username mentions in release notes
  • Loading branch information
Gawdl3y authored Dec 19, 2023
2 parents 181ed46 + a326d1e commit 27363f9
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions ui/src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@ import { marked } from 'marked';
import purify from 'dompurify';

/**
* Full URL to the project's GitHub repository
* GitHub's base URL without a trailing slash
*/
export const REPO_URL = 'https://github.com/Gawdl3y/Resolute/';
export const GITHUB_URL = 'https://github.com';

/**
* Full URL to the project's GitHub repository without a trailing slash
*/
export const REPO_URL = `${GITHUB_URL}/Gawdl3y/Resolute`;

/**
* Renders Markdown into sanitized HTMl with auto-linked GitHub issue numbers and commit hashes
Expand All @@ -15,13 +20,19 @@ export function renderMarkdown(markdown) {
// Replace git hashes with Markdown links
markdown = markdown.replace(
/\b(([0-9a-f]{7})([0-9a-f]{1,33})?)\b/g,
`[$2](${REPO_URL}commit/$1)`,
`[$2](${REPO_URL}/commit/$1)`,
);

// Replace issue numbers with Markdown links
markdown = markdown.replace(
/(\s)(#[0-9]+)\b/g,
`$1[$2](${REPO_URL}issues/$1)`,
`$1[$2](${REPO_URL}/issues/$1)`,
);

// Replace GitHub username mentions with Markdown links
markdown = markdown.replace(
/(\s)@([a-z0-9](?:[a-z0-9]|-(?=[a-z0-9])){0,38})\b/gi,
`$1[@$2](${GITHUB_URL}/$2)`,
);

// Set up the marked renderer to make links open in a new window
Expand Down

0 comments on commit 27363f9

Please sign in to comment.