@@ -1166,26 +1166,29 @@ public function getCurrentUrl($fromStore = true)
11661166 if (!$ this ->isUseStoreInUrl ()) {
11671167 $ storeParsedQuery ['___store ' ] = $ this ->getCode ();
11681168 }
1169- if ($ this ->getCode () !== $ this ->_storeManager ->getStore ()->getCode ()) {
1170- $ fromStore = true ;
1171- }
1169+
11721170 if ($ fromStore !== false ) {
11731171 $ storeParsedQuery ['___from_store ' ] = $ fromStore ===
11741172 true ? $ this ->_storeManager ->getStore ()->getCode () : $ fromStore ;
11751173 }
11761174
1175+ $ requestStringParts = explode ('? ' , $ requestString , 2 );
1176+ $ requestStringPath = $ requestStringParts [0 ];
1177+ if (isset ($ requestStringParts [1 ])) {
1178+ parse_str ($ requestStringParts [1 ], $ requestString );
1179+ } else {
1180+ $ requestString = [];
1181+ }
1182+
1183+ $ currentUrlQueryParams = array_merge ($ requestString , $ storeParsedQuery );
1184+
11771185 $ currentUrl = $ storeParsedUrl ['scheme ' ]
11781186 . ':// '
11791187 . $ storeParsedUrl ['host ' ]
11801188 . (isset ($ storeParsedUrl ['port ' ]) ? ': ' . $ storeParsedUrl ['port ' ] : '' )
1181- . $ storeParsedUrl ['path ' ];
1182-
1183- //avoid query params duplication
1184- if (!preg_match ('/___store=(.*?)&___from_store=(.*?)/ ' , $ requestString )) {
1185- $ currentUrl .= $ requestString ;
1186- }
1187-
1188- $ currentUrl .= ($ storeParsedQuery ? '? ' . http_build_query ($ storeParsedQuery , '' , '& ' ) : '' );
1189+ . $ storeParsedUrl ['path ' ]
1190+ . $ requestStringPath
1191+ . ($ currentUrlQueryParams ? '? ' . http_build_query ($ currentUrlQueryParams , '' , '& ' ) : '' );
11891192
11901193 return $ currentUrl ;
11911194 }
0 commit comments