@@ -211,7 +211,7 @@ public function localizeURL($url = null, $locale = null)
211
211
* @param string|bool $locale Locale to adapt, false to remove locale
212
212
* @param string|false $url URL to adapt in the current language. If not passed, the current url would be taken.
213
213
* @param array $attributes Attributes to add to the route, if empty, the system would try to extract them from the url.
214
- * @param bool $forceDefaultLocation Force to show default location even hideDefaultLocaleInURL set as TRUE
214
+ * @param bool $forceDefaultLocation Force to show default location even hideDefaultLocaleInURL set as TRUE
215
215
*
216
216
* @throws SupportedLocalesNotDefined
217
217
* @throws UnsupportedLocaleException
@@ -829,7 +829,7 @@ protected function extractAttributes($url = false, $locale = '')
829
829
return [];
830
830
}
831
831
832
- $ attributes = $ this ->router ->current ()->parameters ();
832
+ $ attributes = $ this ->normalizeAttributes ( $ this -> router ->current ()->parameters () );
833
833
$ response = event ('routes.translation ' , [$ locale , $ attributes ]);
834
834
835
835
if (!empty ($ response )) {
@@ -876,4 +876,19 @@ protected function unparseUrl($parsed_url)
876
876
877
877
return $ url ;
878
878
}
879
+
880
+ /**
881
+ * Normalize attributes gotten from request parameters.
882
+ *
883
+ * @param array $attributes The attributes
884
+ * @return array The normalized attributes
885
+ */
886
+ protected function normalizeAttributes ($ attributes )
887
+ {
888
+ if (array_key_exists ('data ' , $ attributes ) && is_array ($ attributes ['data ' ]) && ! count ($ attributes ['data ' ])) {
889
+ $ attributes ['data ' ] = null ;
890
+ return $ attributes ;
891
+ }
892
+ return $ attributes ;
893
+ }
879
894
}
0 commit comments