fix: Update URL resolution logic to handle search parameters on root path /?foo=bar (#78262)
## What?
This PR fixes and implements test for an URL resolution issue that
stripped the searchparam when `metadataBase` was defined and a search
param was set on the root path. This created a behavior where :
```
export const metadata: Metadata = {
title: "Create Next App",
description: "Generated by create next app",
metadataBase: new URL("https://www.example.com"),
alternates: {
canonical: "/?foo=bar",
},
};
```
would result in
`<link rel="canonical" href="https://www.example.com">`
instead of
`<link rel="canonical" href="https://www.example.com/?foo=bar">`
## Related issues
- Fixes #65776
- Fixes #74689
Co-authored-by: Jiwon Choi <devjiwonchoi@gmail.com>