Skip to content

Commit

Permalink
Fix badge url issue (#608)
Browse files Browse the repository at this point in the history
Closes #603

Signed-off-by: Cintia Sanchez Garcia <[email protected]>
  • Loading branch information
cynthia-sg authored Apr 30, 2024
1 parent e836175 commit d11df7c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ui/webapp/src/layout/common/itemModal/BadgeModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { BASE_PATH, FOUNDATION } from '../../../data';
import { SVGIconKind } from '../../../types';
import formatShieldsBadgeContent from '../../../utils/formatShieldsBadgeContent';
import CodeBlock from '../CodeBlock';
import Modal from '../Modal';
import SVGIcon from '../SVGIcon';
Expand All @@ -16,7 +17,7 @@ const BadgeModal = (props: Props) => {
const openStatus = () => props.openStatus;
const origin = window.location.origin;
const foundation = FOUNDATION;
const badgeImage = `https://img.shields.io/badge/${foundation}%20Landscape-5699C6`;
const badgeImage = `https://img.shields.io/badge/${formatShieldsBadgeContent(foundation)}%20Landscape-5699C6`;
const markdownLink = () => `[![${foundation} Landscape](${badgeImage})](${origin}${BASE_PATH}/?item=${itemId()})`;
const asciiLink = () => `${origin}${BASE_PATH}/?item=${itemId()}[image:${badgeImage}[${foundation} LANDSCAPE]]`;

Expand Down
10 changes: 10 additions & 0 deletions ui/webapp/src/utils/formatShieldsBadgeContent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { REGEX_DASH } from '../data';

// `badgeContent` message needs double dash instead of single dash,
// due to single dash being used as a separator by shields.io
// https://shields.io/badges/static-badge
const formatShieldsBadgeContent = (n: string): string => {
return n.replace(REGEX_DASH, '--');
};

export default formatShieldsBadgeContent;

0 comments on commit d11df7c

Please sign in to comment.