mnfst 0.5.46 → 0.5.48

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -97,6 +97,38 @@ function initializeLocalizationPlugin() {
97
97
  const currentUrl = new URL(window.location.href);
98
98
  const pathParts = currentUrl.pathname.split('/').filter(Boolean);
99
99
  const hasLanguageInUrl = pathParts[0] && availableLocales.includes(pathParts[0]);
100
+
101
+ // Determine path segments without any current locale prefix, for exclude-pattern checking.
102
+ const pathWithoutLocale = hasLanguageInUrl ? pathParts.slice(1) : pathParts;
103
+
104
+ // If the current path matches a manifest:locale-route-exclude pattern, do NOT add or
105
+ // change the locale prefix — this prevents an infinite redirect loop on prerendered
106
+ // builds where normalizeRedundantLocalePrefixInUrl() strips the locale from the URL
107
+ // but the localization init would otherwise re-add it via window.location.assign().
108
+ const routeExcludeMeta = document.querySelector('meta[name="manifest:locale-route-exclude"]');
109
+ if (routeExcludeMeta) {
110
+ try {
111
+ const rawContent = (routeExcludeMeta.getAttribute('content') || '').replace(/"/g, '"');
112
+ const patterns = JSON.parse(rawContent);
113
+ if (Array.isArray(patterns) && patterns.length > 0) {
114
+ const lower = pathWithoutLocale.map(s => s.toLowerCase());
115
+ for (const pattern of patterns) {
116
+ const p = String(pattern).trim().replace(/^\/+/, '').split('/').filter(Boolean).map(x => x.toLowerCase());
117
+ if (p.length === 0) continue;
118
+ if (lower.length < p.length) continue;
119
+ let match = true;
120
+ for (let i = 0; i < p.length; i++) {
121
+ if (lower[i] !== p[i]) { match = false; break; }
122
+ }
123
+ if (match) {
124
+ // Path is locale-excluded — return URL unchanged so no navigation is triggered
125
+ return currentUrl.toString();
126
+ }
127
+ }
128
+ }
129
+ } catch { /* ignore JSON parse errors */ }
130
+ }
131
+
100
132
  if (hasLanguageInUrl) pathParts[0] = newLang;
101
133
  else pathParts.unshift(newLang);
102
134
  currentUrl.pathname = '/' + pathParts.join('/');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mnfst",
3
- "version": "0.5.46",
3
+ "version": "0.5.48",
4
4
  "private": false,
5
5
  "workspaces": [
6
6
  "templates/starter",