diff --git a/.changeset/lucky-cows-design.md b/.changeset/lucky-cows-design.md new file mode 100644 index 0000000000..2330bdbab6 --- /dev/null +++ b/.changeset/lucky-cows-design.md @@ -0,0 +1,6 @@ +--- +"@fuel-wallet/connections": patch +"@fuels/playwright-utils": patch +--- + +Fix provider overriding url diff --git a/packages/connections/src/utils/provider.ts b/packages/connections/src/utils/provider.ts index c7b0f84594..22fa263132 100644 --- a/packages/connections/src/utils/provider.ts +++ b/packages/connections/src/utils/provider.ts @@ -21,34 +21,6 @@ export const createProvider = async (url: string) => { if (providers[url]) { return providers[url]; } - - // Regular expression to match the URL with basic auth credentials - const regex = /^(https?:\/\/)([^:@]+):([^:@]+)@(.*)$/; - const match = url.match(regex); - - let username: string | undefined; - let password: string | undefined; - let urlNoBasicAuth = url; - if (match) { - // Extract username and password from the match - username = match[2]; - password = match[3]; - // Remove the username and password from the URL - urlNoBasicAuth = url.replace(`${match[2]}:${match[3]}@`, ''); - } - - // create provider with the URL without basic auth credentials - providers[url] = await Provider.create(urlNoBasicAuth, { - requestMiddleware: async (req) => { - if (req?.headers && username && password) { - // Add basic auth credentials to the request following browser way - const auth = `Basic ${btoa(`${username}:${password}`)}`; - // biome-ignore lint/complexity/useLiteralKeys: - req.headers['Authorization'] = `${auth}`; - } - return req; - }, - }); - + providers[url] = await Provider.create(url); return providers[url]; };