Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2479 - Normalize group name string in 'GroupLeaveModal.vue' #2489

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 9 additions & 0 deletions frontend/model/contracts/shared/giLodash.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,15 @@ export function randomHexString (length: number): string {
return Array.from(randomBytes(length), byte => (byte % 16).toString(16)).join('')
}

export function normalizeString (str: string): string {
return str
// [1]. Normalize strings by replacing both apostrophes and single quotes with a standard character (reference issue: https://github.com/okTurtles/group-income/issues/2479)
.replace(/['’]/g, "'")
SebinSong marked this conversation as resolved.
Show resolved Hide resolved
// [2]. Normalize the string based on 'Canonical equivalence'. eg) 'Amélie' !== 'Amélie' even when they are visually identical because their unicode sequences are different.
// (reference: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize#canonical_equivalence_normalization)
.normalize('NFC')
}

export function randomIntFromRange (min: number, max: number): number {
return Math.floor(Math.random() * (max - min + 1) + min)
}
Expand Down
3 changes: 2 additions & 1 deletion frontend/views/containers/group-settings/GroupLeaveModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ import BannerSimple from '@components/banners/BannerSimple.vue'
import BannerScoped from '@components/banners/BannerScoped.vue'
import ButtonSubmit from '@components/ButtonSubmit.vue'
import validationsDebouncedMixins from '@view-utils/validationsDebouncedMixins.js'
import { normalizeString } from '@model/contracts/shared/giLodash.js'

export default ({
name: 'GroupLeaveModal',
Expand Down Expand Up @@ -132,7 +133,7 @@ export default ({
confirmation: {
[L('This field is required')]: required,
[L('Does not match')]: function (value) {
return value === this.code
return normalizeString(value) === normalizeString(this.code)
}
}
}
Expand Down