oas 17.8.1 → 17.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.js +5 -4
- package/package.json +1 -1
- package/src/index.ts +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## <small>17.8.2 (2022-03-21)</small>
|
|
2
|
+
|
|
3
|
+
* fix: issue where hostname server variables wouldn't match subdomains or ports (#623) ([0630600](https://github.com/readmeio/oas/commit/0630600)), closes [#623](https://github.com/readmeio/oas/issues/623)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
1
7
|
## <small>17.8.1 (2022-03-04)</small>
|
|
2
8
|
|
|
3
9
|
* fix: typo in the `--pattern` option ([42db80a](https://github.com/readmeio/oas/commit/42db80a))
|
package/dist/index.js
CHANGED
|
@@ -84,6 +84,7 @@ exports.Callback = operation_1.Callback;
|
|
|
84
84
|
exports.Webhook = operation_1.Webhook;
|
|
85
85
|
var utils_1 = __importStar(require("./utils"));
|
|
86
86
|
exports.utils = utils_1["default"];
|
|
87
|
+
var SERVER_VARIABLE_REGEX = /{([-_a-zA-Z0-9:.[\]]+)}/g;
|
|
87
88
|
function ensureProtocol(url) {
|
|
88
89
|
// Add protocol to urls starting with // e.g. //example.com
|
|
89
90
|
// This is because httpsnippet throws a HARError when it doesnt have a protocol
|
|
@@ -137,12 +138,12 @@ function normalizedUrl(api, selected) {
|
|
|
137
138
|
*
|
|
138
139
|
* For example, when given `https://{region}.node.example.com/v14` this will return back:
|
|
139
140
|
*
|
|
140
|
-
* https://([-_a-zA-Z0-9[\\]]+).node.example.com/v14
|
|
141
|
+
* https://([-_a-zA-Z0-9:.[\\]]+).node.example.com/v14
|
|
141
142
|
*
|
|
142
143
|
* @param url URL to transform
|
|
143
144
|
*/
|
|
144
145
|
function transformUrlIntoRegex(url) {
|
|
145
|
-
return stripTrailingSlash(url.replace(
|
|
146
|
+
return stripTrailingSlash(url.replace(SERVER_VARIABLE_REGEX, '([-_a-zA-Z0-9:.[\\]]+)'));
|
|
146
147
|
}
|
|
147
148
|
/**
|
|
148
149
|
* Normalize a path so that we can use it with `path-to-regexp` to do operation lookups.
|
|
@@ -362,7 +363,7 @@ var Oas = /** @class */ (function () {
|
|
|
362
363
|
// way we'll be able to extract the parameter names and match them up with the matched server that we obtained
|
|
363
364
|
// above.
|
|
364
365
|
var variables = {};
|
|
365
|
-
Array.from(server.url.matchAll(
|
|
366
|
+
Array.from(server.url.matchAll(SERVER_VARIABLE_REGEX)).forEach(function (variable, y) {
|
|
366
367
|
variables[variable[1]] = found[y + 1];
|
|
367
368
|
});
|
|
368
369
|
return {
|
|
@@ -396,7 +397,7 @@ var Oas = /** @class */ (function () {
|
|
|
396
397
|
if (variables === void 0) { variables = {}; }
|
|
397
398
|
// When we're constructing URLs, server URLs with trailing slashes cause problems with doing lookups, so if we have
|
|
398
399
|
// one here on, slice it off.
|
|
399
|
-
return stripTrailingSlash(url.replace(
|
|
400
|
+
return stripTrailingSlash(url.replace(SERVER_VARIABLE_REGEX, function (original, key) {
|
|
400
401
|
var userVariable = (0, get_user_variable_1["default"])(_this.user, key);
|
|
401
402
|
if (userVariable) {
|
|
402
403
|
return userVariable;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -24,6 +24,8 @@ type PathMatches = PathMatch[];
|
|
|
24
24
|
|
|
25
25
|
type Variables = Record<string, string | number | { default?: string | number }[] | { default?: string | number }>;
|
|
26
26
|
|
|
27
|
+
const SERVER_VARIABLE_REGEX = /{([-_a-zA-Z0-9:.[\]]+)}/g;
|
|
28
|
+
|
|
27
29
|
function ensureProtocol(url: string) {
|
|
28
30
|
// Add protocol to urls starting with // e.g. //example.com
|
|
29
31
|
// This is because httpsnippet throws a HARError when it doesnt have a protocol
|
|
@@ -84,12 +86,12 @@ function normalizedUrl(api: RMOAS.OASDocument, selected: number) {
|
|
|
84
86
|
*
|
|
85
87
|
* For example, when given `https://{region}.node.example.com/v14` this will return back:
|
|
86
88
|
*
|
|
87
|
-
* https://([-_a-zA-Z0-9[\\]]+).node.example.com/v14
|
|
89
|
+
* https://([-_a-zA-Z0-9:.[\\]]+).node.example.com/v14
|
|
88
90
|
*
|
|
89
91
|
* @param url URL to transform
|
|
90
92
|
*/
|
|
91
93
|
function transformUrlIntoRegex(url: string) {
|
|
92
|
-
return stripTrailingSlash(url.replace(
|
|
94
|
+
return stripTrailingSlash(url.replace(SERVER_VARIABLE_REGEX, '([-_a-zA-Z0-9:.[\\]]+)'));
|
|
93
95
|
}
|
|
94
96
|
|
|
95
97
|
/**
|
|
@@ -365,7 +367,7 @@ export default class Oas {
|
|
|
365
367
|
// way we'll be able to extract the parameter names and match them up with the matched server that we obtained
|
|
366
368
|
// above.
|
|
367
369
|
const variables: Record<string, string | number> = {};
|
|
368
|
-
Array.from(server.url.matchAll(
|
|
370
|
+
Array.from(server.url.matchAll(SERVER_VARIABLE_REGEX)).forEach((variable, y) => {
|
|
369
371
|
variables[variable[1]] = found[y + 1];
|
|
370
372
|
});
|
|
371
373
|
|
|
@@ -401,7 +403,7 @@ export default class Oas {
|
|
|
401
403
|
// When we're constructing URLs, server URLs with trailing slashes cause problems with doing lookups, so if we have
|
|
402
404
|
// one here on, slice it off.
|
|
403
405
|
return stripTrailingSlash(
|
|
404
|
-
url.replace(
|
|
406
|
+
url.replace(SERVER_VARIABLE_REGEX, (original: string, key: string) => {
|
|
405
407
|
const userVariable = getUserVariable(this.user, key);
|
|
406
408
|
if (userVariable) {
|
|
407
409
|
return userVariable as string;
|