mongodb-connection-string-url
Advanced tools
Comparing version 1.1.0 to 1.1.1
import { URL } from 'whatwg-url'; | ||
declare class CaseInsensitiveMap extends Map<string, string> { | ||
delete(name: any): boolean; | ||
get(name: any): string | null; | ||
has(name: any): boolean; | ||
set(name: any, value: any): this; | ||
_normalizeKey(name: any): string; | ||
} | ||
declare abstract class URLWithoutHost extends URL { | ||
@@ -29,3 +36,3 @@ abstract get host(): never; | ||
} | ||
export declare class CommaAndColonSeparatedRecord extends Map<string, string> { | ||
export declare class CommaAndColonSeparatedRecord extends CaseInsensitiveMap { | ||
constructor(from?: string | null); | ||
@@ -32,0 +39,0 @@ toString(): string; |
@@ -7,6 +7,3 @@ "use strict"; | ||
const HOSTS_REGEX = new RegExp(String.raw `(?<protocol>mongodb(?:\+srv|)):\/\/(?:(?<username>[^:]*)(?::(?<password>[^@]*))?@)?(?<hosts>(?!:)[^\/?@]+)(?<rest>.*)`); | ||
const caseInsenstiveURLSearchParams = (Ctor) => class CaseInsenstiveURLSearchParams extends Ctor { | ||
append(name, value) { | ||
return super.append(this._normalizeKey(name), value); | ||
} | ||
class CaseInsensitiveMap extends Map { | ||
delete(name) { | ||
@@ -18,5 +15,2 @@ return super.delete(this._normalizeKey(name)); | ||
} | ||
getAll(name) { | ||
return super.getAll(this._normalizeKey(name)); | ||
} | ||
has(name) { | ||
@@ -38,2 +32,25 @@ return super.has(this._normalizeKey(name)); | ||
} | ||
} | ||
const caseInsenstiveURLSearchParams = (Ctor) => class CaseInsenstiveURLSearchParams extends Ctor { | ||
append(name, value) { | ||
return super.append(this._normalizeKey(name), value); | ||
} | ||
delete(name) { | ||
return super.delete(this._normalizeKey(name)); | ||
} | ||
get(name) { | ||
return super.get(this._normalizeKey(name)); | ||
} | ||
getAll(name) { | ||
return super.getAll(this._normalizeKey(name)); | ||
} | ||
has(name) { | ||
return super.has(this._normalizeKey(name)); | ||
} | ||
set(name, value) { | ||
return super.set(this._normalizeKey(name), value); | ||
} | ||
_normalizeKey(name) { | ||
return CaseInsensitiveMap.prototype._normalizeKey.call(this, name); | ||
} | ||
}; | ||
@@ -127,11 +144,16 @@ class URLWithoutHost extends whatwg_url_1.URL { | ||
exports.default = ConnectionString; | ||
class CommaAndColonSeparatedRecord extends Map { | ||
class CommaAndColonSeparatedRecord extends CaseInsensitiveMap { | ||
constructor(from) { | ||
super((from !== null && from !== void 0 ? from : '').split(',').filter(Boolean).map(entry => { | ||
super(); | ||
for (const entry of (from !== null && from !== void 0 ? from : '').split(',')) { | ||
if (!entry) | ||
continue; | ||
const colonIndex = entry.indexOf(':'); | ||
if (colonIndex === -1) { | ||
return [entry, '']; | ||
this.set(entry, ''); | ||
} | ||
return [entry.slice(0, colonIndex), entry.slice(colonIndex + 1)]; | ||
})); | ||
else { | ||
this.set(entry.slice(0, colonIndex), entry.slice(colonIndex + 1)); | ||
} | ||
} | ||
} | ||
@@ -138,0 +160,0 @@ toString() { |
{ | ||
"name": "mongodb-connection-string-url", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"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
28373
234