Comparing version 2.0.0 to 2.0.1
@@ -21,3 +21,3 @@ "use strict"; | ||
const connectWebSocketStream = require("websocket-stream"); | ||
const subscriptions_transport_ws_1 = require("subscriptions-transport-ws"); | ||
const subscriptions_transport_ws_1 = require("@httptoolkit/subscriptions-transport-ws"); | ||
const { | ||
@@ -24,0 +24,0 @@ /** @hidden */ |
@@ -5,3 +5,3 @@ /** | ||
import { OngoingRequest, Method, Explainable } from "../types"; | ||
import { Serializable, ClientServerChannel } from "../util/serialization"; | ||
import { Serializable } from "../util/serialization"; | ||
import { MaybePromise } from '../util/type-utils'; | ||
@@ -37,5 +37,2 @@ export interface RequestMatcher extends Explainable, Serializable { | ||
explain(): string; | ||
serialize(channel: ClientServerChannel): { | ||
normalizedUrl: string; | ||
}; | ||
} | ||
@@ -48,5 +45,2 @@ export declare class RegexPathMatcher extends Serializable implements RequestMatcher { | ||
explain(): string; | ||
serialize(channel: ClientServerChannel): { | ||
regexString: string; | ||
}; | ||
} | ||
@@ -53,0 +47,0 @@ export declare class HeaderMatcher extends Serializable implements RequestMatcher { |
@@ -115,8 +115,2 @@ "use strict"; | ||
} | ||
serialize(channel) { | ||
return Object.assign(super.serialize(channel), { | ||
// For backward compat, will used by older (<0.17) servers | ||
normalizedUrl: normalize_url_1.legacyNormalizeUrl(this.path) | ||
}); | ||
} | ||
} | ||
@@ -131,17 +125,8 @@ exports.SimplePathMatcher = SimplePathMatcher; | ||
matches(request) { | ||
if (this.regexSource !== undefined) { | ||
const absoluteUrl = normalize_url_1.normalizeUrl(request.url); | ||
const urlPath = request_utils_1.getPathFromAbsoluteUrl(absoluteUrl); | ||
// Test the matcher against both the path alone & the full URL | ||
const urlMatcher = new RegExp(this.regexSource); | ||
return urlMatcher.test(absoluteUrl) || | ||
urlMatcher.test(urlPath); | ||
} | ||
else { | ||
const { regexString } = this; | ||
// Old client, use old normalization & logic. Without this, old clients that check | ||
// example.com$ will fail to match (they should check ...com/$) | ||
let urlMatcher = new RegExp(regexString); | ||
return urlMatcher.test(normalize_url_1.legacyNormalizeUrl(request.url)); | ||
} | ||
const absoluteUrl = normalize_url_1.normalizeUrl(request.url); | ||
const urlPath = request_utils_1.getPathFromAbsoluteUrl(absoluteUrl); | ||
// Test the matcher against both the path alone & the full URL | ||
const urlMatcher = new RegExp(this.regexSource); | ||
return urlMatcher.test(absoluteUrl) || | ||
urlMatcher.test(urlPath); | ||
} | ||
@@ -151,8 +136,2 @@ explain() { | ||
} | ||
serialize(channel) { | ||
return Object.assign(super.serialize(channel), { | ||
// Backward compat for old servers | ||
regexString: this.regexSource | ||
}); | ||
} | ||
} | ||
@@ -159,0 +138,0 @@ exports.RegexPathMatcher = RegexPathMatcher; |
@@ -28,3 +28,3 @@ "use strict"; | ||
const schema_1 = require("@graphql-tools/schema"); | ||
const subscriptions_transport_ws_1 = require("subscriptions-transport-ws"); | ||
const subscriptions_transport_ws_1 = require("@httptoolkit/subscriptions-transport-ws"); | ||
const connectWebSocketStream = require("websocket-stream"); | ||
@@ -31,0 +31,0 @@ const DuplexPair = require("native-duplexpair"); |
@@ -5,3 +5,2 @@ /** | ||
import * as _ from 'lodash'; | ||
export declare const legacyNormalizeUrl: ((url: string) => string) & _.MemoizedFunction; | ||
/** | ||
@@ -8,0 +7,0 @@ * Normalizes URLs to the form used when matching them. |
@@ -6,14 +6,6 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.normalizeUrl = exports.legacyNormalizeUrl = void 0; | ||
exports.normalizeUrl = void 0; | ||
const url = require("url"); | ||
const _ = require("lodash"); | ||
const normalize = require("normalize-url"); | ||
const request_utils_1 = require("./request-utils"); | ||
// Preserved so we can correctly normalize serialized data, for backward compat | ||
// with legacy servers. | ||
exports.legacyNormalizeUrl = _.memoize((url) => normalize(url, { | ||
stripWWW: false, | ||
removeTrailingSlash: false, | ||
removeQueryParameters: [/.*/], | ||
})); | ||
/** | ||
@@ -20,0 +12,0 @@ * Normalizes URLs to the form used when matching them. |
{ | ||
"name": "mockttp", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Mock HTTP server for testing HTTP clients and stubbing webservices", | ||
@@ -79,3 +79,2 @@ "main": "dist/main.js", | ||
"@types/mocha": "2.2.48", | ||
"@types/normalize-url": "1.9.1", | ||
"@types/request": "2.48.2", | ||
@@ -127,2 +126,3 @@ "@types/semver": "5.5.0", | ||
"@httptoolkit/httpolyglot": "^1.0.0", | ||
"@httptoolkit/subscriptions-transport-ws": "^0.9.19", | ||
"@types/cors": "^2.8.6", | ||
@@ -149,7 +149,5 @@ "@types/express": "^4.0.33", | ||
"node-forge": "^0.10.0", | ||
"normalize-url": "^1.9.1", | ||
"performance-now": "^2.1.0", | ||
"portfinder": "^1.0.23", | ||
"proxy-agent": "^4.0.1", | ||
"subscriptions-transport-ws": "^0.9.4", | ||
"typed-error": "^3.0.2", | ||
@@ -156,0 +154,0 @@ "universal-websocket-client": "^1.0.2", |
@@ -10,3 +10,3 @@ /** | ||
import connectWebSocketStream = require('websocket-stream'); | ||
import { SubscriptionClient } from 'subscriptions-transport-ws'; | ||
import { SubscriptionClient } from '@httptoolkit/subscriptions-transport-ws'; | ||
import { Duplex } from 'stream'; | ||
@@ -13,0 +13,0 @@ |
@@ -18,3 +18,3 @@ /** | ||
import { MaybePromise } from '../util/type-utils'; | ||
import { normalizeUrl, legacyNormalizeUrl } from '../util/normalize-url'; | ||
import { normalizeUrl } from '../util/normalize-url'; | ||
@@ -131,9 +131,2 @@ export interface RequestMatcher extends Explainable, Serializable { | ||
} | ||
serialize(channel: ClientServerChannel) { | ||
return Object.assign(super.serialize(channel), { | ||
// For backward compat, will used by older (<0.17) servers | ||
normalizedUrl: legacyNormalizeUrl(this.path) | ||
}); | ||
} | ||
} | ||
@@ -151,18 +144,9 @@ | ||
matches(request: OngoingRequest) { | ||
if (this.regexSource !== undefined) { | ||
const absoluteUrl = normalizeUrl(request.url); | ||
const urlPath = getPathFromAbsoluteUrl(absoluteUrl); | ||
const absoluteUrl = normalizeUrl(request.url); | ||
const urlPath = getPathFromAbsoluteUrl(absoluteUrl); | ||
// Test the matcher against both the path alone & the full URL | ||
const urlMatcher = new RegExp(this.regexSource); | ||
return urlMatcher.test(absoluteUrl) || | ||
urlMatcher.test(urlPath); | ||
} else { | ||
const { regexString } = (this as this & { regexString: string }); | ||
// Old client, use old normalization & logic. Without this, old clients that check | ||
// example.com$ will fail to match (they should check ...com/$) | ||
let urlMatcher = new RegExp(regexString); | ||
return urlMatcher.test(legacyNormalizeUrl(request.url)); | ||
} | ||
// Test the matcher against both the path alone & the full URL | ||
const urlMatcher = new RegExp(this.regexSource); | ||
return urlMatcher.test(absoluteUrl) || | ||
urlMatcher.test(urlPath); | ||
} | ||
@@ -174,8 +158,2 @@ | ||
serialize(channel: ClientServerChannel) { | ||
return Object.assign(super.serialize(channel), { | ||
// Backward compat for old servers | ||
regexString: this.regexSource | ||
}); | ||
} | ||
} | ||
@@ -182,0 +160,0 @@ |
@@ -21,3 +21,3 @@ /** | ||
import { makeExecutableSchema } from '@graphql-tools/schema'; | ||
import { SubscriptionServer } from 'subscriptions-transport-ws'; | ||
import { SubscriptionServer } from '@httptoolkit/subscriptions-transport-ws'; | ||
import connectWebSocketStream = require('websocket-stream'); | ||
@@ -24,0 +24,0 @@ import { Duplex } from 'stream'; |
@@ -7,18 +7,5 @@ /** | ||
import * as _ from 'lodash'; | ||
import * as normalize from "normalize-url"; | ||
import { isAbsoluteProtocollessUrl } from './request-utils'; | ||
// Preserved so we can correctly normalize serialized data, for backward compat | ||
// with legacy servers. | ||
export const legacyNormalizeUrl = | ||
_.memoize( | ||
(url: string): string => | ||
normalize(url, { | ||
stripWWW: false, | ||
removeTrailingSlash: false, | ||
removeQueryParameters: [/.*/], | ||
}) | ||
); | ||
/** | ||
@@ -25,0 +12,0 @@ * Normalizes URLs to the form used when matching them. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
32
51
907974
16343
+ Added@httptoolkit/subscriptions-transport-ws@0.9.19(transitive)
- Removednormalize-url@^1.9.1
- Removedsubscriptions-transport-ws@^0.9.4
- Removedis-plain-obj@1.1.0(transitive)
- Removednormalize-url@1.9.1(transitive)
- Removedprepend-http@1.0.4(transitive)
- Removedquery-string@4.3.4(transitive)
- Removedsort-keys@1.1.2(transitive)
- Removedstrict-uri-encode@1.1.0(transitive)
- Removedsubscriptions-transport-ws@0.9.19(transitive)