fix(SW-449): Moved normalizeDate outside middleware
This commit is contained in:
@@ -7,9 +7,6 @@ Middleware function to normalize date formats to support
|
|||||||
YYYY-MM-D and YYYY-MM-DD since the current web uses YYYY-MM-D
|
YYYY-MM-D and YYYY-MM-DD since the current web uses YYYY-MM-D
|
||||||
in the URL as parameters (toDate and fromDate)
|
in the URL as parameters (toDate and fromDate)
|
||||||
*/
|
*/
|
||||||
export const middleware: NextMiddleware = (request) => {
|
|
||||||
const url = request.nextUrl.clone()
|
|
||||||
const { searchParams } = url
|
|
||||||
|
|
||||||
function normalizeDate(date: string): string {
|
function normalizeDate(date: string): string {
|
||||||
const datePattern = /^\d{4}-\d{1,2}-\d{1,2}$/
|
const datePattern = /^\d{4}-\d{1,2}-\d{1,2}$/
|
||||||
@@ -20,6 +17,10 @@ export const middleware: NextMiddleware = (request) => {
|
|||||||
return date
|
return date
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const middleware: NextMiddleware = (request) => {
|
||||||
|
const url = request.nextUrl.clone()
|
||||||
|
const { searchParams } = url
|
||||||
|
|
||||||
if (searchParams.has("fromDate")) {
|
if (searchParams.has("fromDate")) {
|
||||||
const fromDate = searchParams.get("fromDate")!
|
const fromDate = searchParams.get("fromDate")!
|
||||||
searchParams.set("fromDate", normalizeDate(fromDate))
|
searchParams.set("fromDate", normalizeDate(fromDate))
|
||||||
|
|||||||
Reference in New Issue
Block a user