Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ui/common/src/data/data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const REGEX_DASH = /-/g;
export const REGEX_URL = /^https?:\/\//;
export const REGEX_UNDERSCORE = /_/g;
export const REGEX_SPACE = /\s/g;

export const BANNER_ID = 'banner-event';
14 changes: 9 additions & 5 deletions ui/common/src/utils/formatShieldsBadgeContent.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { REGEX_DASH } from '../data/data';
// `badgeContent` message needs double dash instead of single dash,
// due to single dash being used as a separator by shields.io

import { REGEX_DASH, REGEX_UNDERSCORE, REGEX_SPACE } from '../data/data';
// `badgeContent` message needs special character handling for shields.io:
// - Single dash → double dash (dash is used as separator)
// - Space → %20 (proper URL encoding)
// - Underscore → double underscore (underscore renders as space in badge)
// https://shields.io/badges/static-badge
export const formatShieldsBadgeContent = (n: string): string => {
return n.replace(REGEX_DASH, '--');
return n
.replace(REGEX_DASH, '--')
.replace(REGEX_UNDERSCORE, '__')
.replace(REGEX_SPACE, '%20');
};