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
12 changes: 6 additions & 6 deletions frontend/__tests__/unit/components/AnchorTitle.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ jest.mock('utils/slugify', () => ({
default: jest.fn((str: string) =>
str
.toLowerCase()
.replace(/[^a-z0-9]/g, '-')
.replace(/-{2,10}/g, '-')
.replace(/(^-{1,10}|-{1,10}$)/g, '')
.replaceAll(/[^a-z0-9]/g, '-')
.replaceAll(/-{2,10}/g, '-')
.replaceAll(/(^-{1,10}|-{1,10}$)/g, '')
),
}))

Expand Down Expand Up @@ -652,9 +652,9 @@ describe('AnchorTitle Component', () => {
mockFn.mockImplementation((str: string) =>
str
.toLowerCase()
.replace(/[^a-z0-9]/g, '-')
.replace(/-{2,10}/g, '-')
.replace(/(^-{1,10}|-{1,10}$)/g, '')
.replaceAll(/[^a-z0-9]/g, '-')
.replaceAll(/-{2,10}/g, '-')
.replaceAll(/(^-{1,10}|-{1,10}$)/g, '')
)

const mockScrollTo = jest.spyOn(globalThis, 'scrollTo').mockImplementation()
Expand Down
4 changes: 2 additions & 2 deletions frontend/__tests__/unit/components/MarkdownWrapper.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ jest.mock('markdown-it/index.mjs', () => {
render: (content: string) => {
// Very simple mock: replace **bold** and [link](url)
return content
.replace(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
.replace(/\[(.*?)\]\((.*?)\)/g, '<a href="$2">$1</a>')
.replaceAll(/\*\*(.*?)\*\*/g, '<strong>$1</strong>')
.replaceAll(/\[(.*?)\]\((.*?)\)/g, '<a href="$2">$1</a>')
},
use: jest.fn().mockReturnThis(),
}))
Expand Down
2 changes: 1 addition & 1 deletion frontend/__tests__/unit/pages/UserDetails.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jest.mock('components/Badges', () => {
showTooltip?: boolean
}) => (
<div
data-testid={`badge-${name.toLowerCase().replace(/\s+/g, '-')}`}
data-testid={`badge-${name.toLowerCase().replaceAll(/\s+/g, '-')}`}
data-css-class={cssClass}
data-show-tooltip={showTooltip}
>
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/board/[year]/candidates/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ const BoardCandidatesPage = () => {

const handleCardClick = () => {
// Convert name to slug format.
const nameSlug = candidate.memberName.toLowerCase().replace(/\s+/g, '_')
const nameSlug = candidate.memberName.toLowerCase().replaceAll(/\s+/g, '_')
const candidateUrl = `https://owasp.org/www-board-candidates/${year}/${nameSlug}.html`
window.open(candidateUrl, '_blank', 'noopener,noreferrer')
}
Expand Down Expand Up @@ -295,7 +295,7 @@ const BoardCandidatesPage = () => {
}
className="text-gray-700 dark:text-gray-300"
>
{candidate.member.bio.replace(/\n+/g, ' ').replace(/\s+/g, ' ').trim()}
{candidate.member.bio.replaceAll(/\n+/g, ' ').replaceAll(/\s+/g, ' ').trim()}
</div>
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/Badges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const normalizeCssClass = (cssClass: string | undefined) => {
}

// Convert backend snake_case format to frontend camelCase format
return cssClass.trim().replace(/_([a-z])/g, (_, letter) => letter.toUpperCase())
return cssClass.trim().replaceAll(/_([a-z])/g, (_, letter) => letter.toUpperCase())
}

const resolveIcon = (cssClass: string | undefined) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/BreadCrumbs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function BreadCrumbs() {

{segments.map((segment, index) => {
const href = homeRoute + segments.slice(0, index + 1).join(homeRoute)
const label = upperFirst(segment).replace(/-/g, ' ')
const label = upperFirst(segment).replaceAll('-', ' ')
const isLast = index === segments.length - 1

return (
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/utils/slugify.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export default function slugify(text: string): string {
return text
.normalize('NFKD') // Normalize accented characters
.replace(/[\u0300-\u036F]/g, '') // Remove diacritics
.replace(/[^a-zA-Z0-9]+/g, '-') // Replace non-alphanumeric with hyphens
.replaceAll(/[\u0300-\u036F]/g, '') // Remove diacritics
.replaceAll(/[^a-zA-Z0-9]+/g, '-') // Replace non-alphanumeric with hyphens
.replace(/^[-]+/, '') // Trim leading hyphens
.replace(/[-]+$/, '') // Trim trailing hyphens
.toLowerCase()
Expand Down