fix: conflict between browser URL object and Node URL object (#3061)

I am running this package using electron, what i noticed was that due to
the fact that the lines between node and browser environments become a
bit blurred, the URL class that was being used was the one defined by
the browser and not node. By making an explicit require it ensures the
correct Class is used.

While creating a test for this would be difficuilt i think adding an
eslint rule to stop using globally defined objects and require imports
instead would resolve issues like this in the future
This commit is contained in:
Sebastien Stettler 2023-09-15 14:22:18 -07:00 committed by GitHub
parent da0f5c5eb2
commit d21cc09556
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,9 @@
'use strict'
//Parse method copied from https://github.com/brianc/node-postgres
//Copyright (c) 2010-2014 Brian Carlson (brian.m.carlson@gmail.com)
//MIT License
const { URL } = require('url')
//parses a connection string
function parse(str) {
//unix socket