UNPKG

nuxt-i18n-micro

Version:

Nuxt I18n Micro is a lightweight, high-performance internationalization module for Nuxt, designed to handle multi-language support with minimal overhead, fast build times, and efficient runtime performance.

41 lines (40 loc) 1.1 kB
const DEFAULT_STATIC_PATTERNS = [ /^\/sitemap.*\.xml$/, /^\/sitemap\.xml$/, /^\/robots\.txt$/, /^\/favicon\.ico$/, /^\/apple-touch-icon.*\.png$/, /^\/manifest\.json$/, /^\/sw\.js$/, /^\/workbox-.*\.js$/, /\.(xml|txt|ico|json|js|css|png|jpg|jpeg|gif|svg|woff|woff2|ttf|eot)$/ ]; export const isInternalPath = (path, excludePatterns) => { if (/(?:^|\/)__[^/]+/.test(path)) { return true; } for (const pattern of DEFAULT_STATIC_PATTERNS) { if (pattern.test(path)) { return true; } } if (excludePatterns) { for (const pattern of excludePatterns) { if (typeof pattern === "string") { if (pattern.includes("*") || pattern.includes("?")) { const regex = new RegExp(pattern.replace(/\*/g, ".*").replace(/\?/g, ".")); if (regex.test(path)) { return true; } } else if (path === pattern || path.startsWith(pattern)) { return true; } } else if (pattern instanceof RegExp) { if (pattern.test(path)) { return true; } } } } return false; };