/
githubmirror
/
wp-calypso
Обзор
Документация
Войти
/
githubmirror
/
wp-calypso
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
client/lib/route/normalize.ts
16 строк
556 B
Jarda Snajdr
Fork page.js into calypso-router package, fix issues with deep call stacks (#84096)
22 ноя 2023, 10:46
Не верифицирован
22 ноя 2023, 10:46
680131e
Код
Авторство
О чём код?
import page, { type Callback } from '@automattic/calypso-router'; import untrailingslashit from './untrailingslashit'; const appendQueryString = ( basepath: string, querystring: string ): string => basepath + ( querystring ? '?' + querystring : '' ); const normalize: Callback = ( context, next ) => { const normalizedPathName = untrailingslashit( context.pathname ); if ( normalizedPathName !== context.pathname ) { page.redirect( appendQueryString( normalizedPathName, context.querystring ) ); } else { next(); } }; export default normalize;