diff options
| author | 2024-04-16 19:48:49 +0800 | |
|---|---|---|
| committer | 2024-04-16 19:48:49 +0800 | |
| commit | 1ce22881c657becf0397b83ac393fb5d2399104c (patch) | |
| tree | 1836b23abc9f9811ac8b2ee0952e50664bfcbc18 /packages/integrations/sitemap/src/utils/parse-url.ts | |
| parent | b2ef6abfffbd56191115bc5788b8753d2bcdac28 (diff) | |
| download | astro-1ce22881c657becf0397b83ac393fb5d2399104c.tar.gz astro-1ce22881c657becf0397b83ac393fb5d2399104c.tar.zst astro-1ce22881c657becf0397b83ac393fb5d2399104c.zip | |
Improve sitemap generate performance (#10795)
Diffstat (limited to 'packages/integrations/sitemap/src/utils/parse-url.ts')
| -rw-r--r-- | packages/integrations/sitemap/src/utils/parse-url.ts | 39 |
1 files changed, 0 insertions, 39 deletions
diff --git a/packages/integrations/sitemap/src/utils/parse-url.ts b/packages/integrations/sitemap/src/utils/parse-url.ts deleted file mode 100644 index f9189cf7d..000000000 --- a/packages/integrations/sitemap/src/utils/parse-url.ts +++ /dev/null @@ -1,39 +0,0 @@ -export const parseUrl = ( - url: string, - defaultLocale: string, - localeCodes: string[], - base: string -) => { - if ( - !url || - !defaultLocale || - localeCodes.length === 0 || - localeCodes.some((key) => !key) || - !base - ) { - throw new Error('parseUrl: some parameters are empty'); - } - if (url.indexOf(base) !== 0) { - return undefined; - } - let s = url.replace(base, ''); - if (!s || s === '/') { - return { locale: defaultLocale, path: '/' }; - } - if (!s.startsWith('/')) { - s = '/' + s; - } - const a = s.split('/'); - const locale = a[1]; - if (localeCodes.some((key) => key === locale)) { - let path = a.slice(2).join('/'); - if (path === '//') { - path = '/'; - } - if (path !== '/' && !path.startsWith('/')) { - path = '/' + path; - } - return { locale, path }; - } - return { locale: defaultLocale, path: s }; -}; |
