Repository: storybook
Issue: [Bug]: Storybook is messing with query params
Labels: bug,help wanted,addon: toolbars,args,sev:S3

### Describe the bug

I remember we already had issues using standard URL Encoding while using v6 so we settled to use base64 instead (using atob/btoa). Now, after upgrading to v7 RC8, I've noticed that changing a `globalTypes` will mess up my value.



### To Reproduce

Open site with query string included (this is a valid base64 string):

```
&foo=aW1wb3J0IHsgdXNlU3RhdGUgfSBmcm9tICdyZWFjdCc7CmltcG9ydCB7IEFjY29yZGlvbiB9IGZyb20gJ0BnZG0tdWkvcmVhY3QtY29tcG9uZW50cyc7Cgpjb25zdCBDb21wb25lbnQgPSAoeyAuLi5wcm9wcyB9KSA9PiB7CiAgY29uc3QgW2V4cGFuZGVkLCBzZXRFeHBhbmRlZF0gPSB1c2VTdGF0ZSgpOwogIHJldHVybiAoCiAgICA8QWNjb3JkaW9uCiAgICAgIGV4cGFuZGVkPXtleHBhbmRlZH0KICAgICAgb25DaGFuZ2U9eyhldnQpID0%2BIHsKICAgICAgICByZXR1cm4gc2V0RXhwYW5kZWQoZXZ0LnRhcmdldC5jaGVja2VkMik7CiAgICAgIH19CiAgICAgIHsuLi5wcm9wc30KICAgID4KICAgICAgPEFjY29yZGlvbi5IZWFkZXI%2BVGl0bGU8L0FjY29yZGlvbi5IZWFkZXI%2BCiAgICAgIDxkaXY%2BVGVzdCBJbSB0aGUgY29udGVudCBvZiB0aGUgYWNjb3JkaW9uPC9kaXY%2BCiAgICA8L0FjY29yZGlvbj4KICApOwp9OwoKIGV4cG9ydCBkZWZhdWx0IENvbXBvbmVudDs%3D
```

Change something custom in `globalTypes`.

Query string becomes (a completely invalid base64 string):

```
&foo=aW1wb3J0IHsgdXNlU3RhdGUgfSBmcm9tICdyZWFjdCc7CmltcG9ydCB7IEZvcm0sIEljb24gfSBmcm9tICdAZ2RtLXVpL3JlYWN0LWNvbXBvbmVudHMnOwoKY29uc3QgRmllbGQgPSAoeyBoZWxwZXJUZXh0ID0gJycsIGxhYmVsID0gJycsIHN0YXR1cy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Y2tib3hlcyIgdmFsdWU9e2Zvcm0uY2hlY2tib3hlc30gb25DaGFuZ2U9e29uQ2hhbmdlfT4KICAgICAgICA8Rm9ybS5DaGVja2JveCB2YWx1ZT0iMSI+Q2hlY2sgMTwvRm9ybS5DaGVja2JveD4KICAgICAgICA8Rm9ybS5DaGVja2JveCB2YWx1ZT0iMiI+Q2hlY2sgMjwvRm9ybS5DaGVja2JveD4KICAgICAgICA8Rm9ybS5DaGVja2JveCB2YWx1ZT0iMyI+Q2hlY2sgMzwvRm9ybS5DaGVja2JveD4KICAgICAgPC9GaWVsZD4KICAgICAgPEZpZWxkIGxhYmVsPSJSYWRpb3MiIGFzPSJmaWVsZHNldCIgb25DaGFuZ2U9e29uQ2hhbmdlfSBuYW1lPSJyYWRpb3MiIHZhbHVlPXtmb3JtLnJhZGlvc30+CiAgICAgICAgPEZvcm0uUmFkaW8gdmFsdWU9IjEiPkNoZWNrIDE8L0Zvcm0uUmFkaW8+CiAgICAgICAgPEZvcm0uUmFkaW8gdmFsdWU9IjIiPkNoZWNrIDI8L0Zvcm0uUmFkaW8+CiAgICAgICAgPEZvcm0uUmFkaW8gdmFsdWU9IjMiPkNoZWNrIDM8L0Zvcm0uUmFkaW8+CiAgICAgIDwvRmllbGQ+CiAgICA8L2Rpdj4KICApOwp9OwoKQ29tcG9uZW50LmRlZmF1bHRQcm9wcyA9IHsKICAiaGVscGVyVGV4dCI6ICJIZWxwZXIgVGV4dCIsCiAgImxhYmVsIjogIlVzZXJuYW1lIiwKICAic3RhdHVzIjogewogICAgInR5cGUiOiAic3VjY2VzcyIsCiAgICAibWVzc2FnZSI6ICJTdGF0dXMgbWVzc2FnZSIKICB9Cn07CgogZXhwb3J0IGRlZmF1bHQgQ29tcG9uZW50Ow==
```

### System

_No response_

### Additional context

Not sure if this existed in v6 before or its a new issue. It's also interesting that it's not always reproducible, changing globals completely clears out all custom query strings sometimes for some reason.