@@ -1166,26 +1166,29 @@ public function getCurrentUrl($fromStore = true)
1166
1166
if (!$ this ->isUseStoreInUrl ()) {
1167
1167
$ storeParsedQuery ['___store ' ] = $ this ->getCode ();
1168
1168
}
1169
- if ($ this ->getCode () !== $ this ->_storeManager ->getStore ()->getCode ()) {
1170
- $ fromStore = true ;
1171
- }
1169
+
1172
1170
if ($ fromStore !== false ) {
1173
1171
$ storeParsedQuery ['___from_store ' ] = $ fromStore ===
1174
1172
true ? $ this ->_storeManager ->getStore ()->getCode () : $ fromStore ;
1175
1173
}
1176
1174
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
+
1177
1185
$ currentUrl = $ storeParsedUrl ['scheme ' ]
1178
1186
. ':// '
1179
1187
. $ storeParsedUrl ['host ' ]
1180
1188
. (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 , '' , '& ' ) : '' );
1189
1192
1190
1193
return $ currentUrl ;
1191
1194
}
0 commit comments