Skip to content

Commit 235fc39

Browse files
refactor(validation): use extracted normalizeRouteRecord service
- Remove local normalizeRouteRecord function from Validation.vue - Import and use normalizeRouteRecord from services/routeNormalization - Improves maintainability and enables dedicated testing - No behavioral change, preserves all existing functionality Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent e1d2435 commit 235fc39

1 file changed

Lines changed: 1 addition & 25 deletions

File tree

src/views/Validation.vue

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ import {
137137
MODIFICATION_VIOLATION,
138138
toValidationDocument,
139139
} from '../services/validationDocument'
140+
import { normalizeRouteRecord } from '../services/routeNormalization.js'
140141
import logger from '../logger.js'
141142
import { useFilesStore } from '../store/files.js'
142143
import { useSignStore } from '../store/sign.js'
@@ -206,31 +207,6 @@ type ValidationErrorResponse = {
206207
}
207208
}
208209
209-
function normalizeRouteRecord(value: unknown, source: 'params' | 'query'): Record<string, string> {
210-
if (typeof value !== 'object' || value === null) {
211-
return {}
212-
}
213-
214-
const result: Record<string, string> = {}
215-
const droppedKeys: string[] = []
216-
for (const [key, entry] of Object.entries(value)) {
217-
if (typeof entry === 'string') {
218-
result[key] = entry
219-
} else {
220-
droppedKeys.push(key)
221-
}
222-
}
223-
224-
if (droppedKeys.length > 0) {
225-
logger.warn('Validation route normalization dropped non-string entries', {
226-
source,
227-
droppedKeys,
228-
})
229-
}
230-
231-
return result
232-
}
233-
234210
function toNumber(value: unknown): number | null {
235211
return typeof value === 'number' && Number.isFinite(value) ? value : null
236212
}

0 commit comments

Comments
 (0)