mongodb-connection-string-url
Advanced tools
Comparing version 2.4.1 to 2.4.2
@@ -8,3 +8,7 @@ "use strict"; | ||
const DUMMY_HOSTNAME = '__this_is_a_placeholder__'; | ||
const HOSTS_REGEX = new RegExp(String.raw `^(?<protocol>mongodb(?:\+srv|)):\/\/(?:(?<username>[^:]*)(?::(?<password>[^@]*))?@)?(?<hosts>(?!:)[^\/?@]+)(?<rest>.*)`); | ||
function connectionStringHasValidScheme(connectionString) { | ||
return (connectionString.startsWith('mongodb://') || | ||
connectionString.startsWith('mongodb+srv://')); | ||
} | ||
const HOSTS_REGEX = new RegExp(String.raw `^(?<protocol>mongodb(?:\+srv|)):\/\/(?:(?<username>[^:]*)(?::(?<password>[^@]*))?@)?(?<hosts>(?!:)[^\/?@]*)(?<rest>.*)`); | ||
class CaseInsensitiveMap extends Map { | ||
@@ -81,2 +85,5 @@ delete(name) { | ||
var _a; | ||
if (!connectionStringHasValidScheme(uri)) { | ||
throw new MongoParseError('Invalid scheme, expected connection string to start with "mongodb://" or "mongodb+srv://"'); | ||
} | ||
const match = uri.match(HOSTS_REGEX); | ||
@@ -83,0 +90,0 @@ if (!match) { |
{ | ||
"name": "mongodb-connection-string-url", | ||
"version": "2.4.1", | ||
"version": "2.4.2", | ||
"description": "MongoDB connection strings, based on the WhatWG URL API", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
36467
341
1