0

The initial URL is

https://robertbarakett.com/products/the-barakett-t-hoodie?option1=Blue+night&option2=S

I traced the HTTP requests. It only does 1 redirect: from

https://robertbarakett.com/products/the-barakett-t-hoodie?option1=Blue+night&option2=S 

to

https://robertbarakett.com/products/the-barakett-hoodie-black?option1=Blue%20night&option2=S.

However, the final URL in the address bar is

https://robertbarakett.com/products/the-barakett-hoodie-black?variant=31966791729263.

I read about changing URL without reloading page:

  1. How do I modify the URL without reloading the page?
  2. Appending parameter to URL without refresh

Since there is no navigation history after loading the web page, it rules out window.history.pushState. Maybe it uses window.history.replaceState? I did a search in the page's source code, didn't find any use of replaceState. So how to verify whether it uses replaceState or other techniques?

j08691
208k33 gold badges269 silver badges281 bronze badges
asked Nov 13, 2020 at 17:34

1 Answer 1

1

Is using window.history.replaceState

In: https://cdn.shopify.com/s/files/1/0061/4134/5903/t/13/assets/theme.js?v=13437044988013674143

Its has:

_updateHistoryState: function(variant) {
 if (!history.replaceState || !variant) {
 return;
 }
 
 var newurl = window.location.protocol + '//' + window.location.host + window.location.pathname + '?variant=' + variant.id;
 window.history.replaceState({path: newurl}, '', newurl);
},

Is the only place in the source which assigns ?variant

Found by downloading site (right-click save-as), then doing a search for ?variant

answered Nov 13, 2020 at 18:03
Sign up to request clarification or add additional context in comments.

3 Comments

Amazing! I searched variant myself and found several reference. But how could you trace it down to that specific JS file? There are quite some JS files.
np, is lots of variant, but only one ?variant. I saved the page, opened in vs-code then did a search Ctrl-Shift-F, was the only file to show up.. It would take too long to look manually through every file or request response
Just realized what you mean by "right-click save-as", that does the trick!

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.