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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { FieldHook } from 'payload'

const format = (val: string): string =>
val
.trim()
.replace(/ /g, '-')
.replace(/[^\w-]+/g, '')
.toLowerCase()
Expand Down
1 change: 1 addition & 0 deletions examples/form-builder/src/utilities/formatSlug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { FieldHook } from 'payload'

const format = (val: string): string =>
val
.trim()
.replace(/ /g, '-')
.replace(/[^\w-]+/g, '')
.toLowerCase()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { FieldHook } from 'payload'

const format = (val: string): string =>
val
.trim()
.replace(/ /g, '-')
.replace(/[^\w-]+/g, '')
.toLowerCase()
Expand Down
1 change: 1 addition & 0 deletions examples/localization/src/fields/slug/formatSlug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { FieldHook } from 'payload'

export const formatSlug = (val: string): string =>
val
.trim()
.replace(/ /g, '-')
.replace(/[^\w-]+/g, '')
.toLowerCase()
Expand Down
1 change: 1 addition & 0 deletions examples/localization/src/hooks/formatSlug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { FieldHook } from 'payload'

const format = (val: string): string =>
val
.trim()
.replace(/ /g, '-')
.replace(/[^\w-]+/g, '')
.toLowerCase()
Expand Down
3 changes: 2 additions & 1 deletion packages/payload/src/utilities/slugify.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const slugify = (val?: string): string | undefined =>
val
?.replace(/ /g, '-')
?.trim()
.replace(/ /g, '-')
.replace(/[^\w-]+/g, '')
.toLowerCase()
1 change: 1 addition & 0 deletions test/live-preview/utilities/formatSlug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { FieldHook } from 'payload'

const format = (val: string): string =>
val
.trim()
.replace(/ /g, '-')
.replace(/[^\w-]+/g, '')
.toLowerCase()
Expand Down
Loading