Skip to content

Commit 5a5469c

Browse files
committed
Minor improvements suggested by @dok in PR comments:
- More robust regex for path matching - findOperation more agnostic
1 parent 701ef96 commit 5a5469c

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/oas.js

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,7 @@ function normalizedUrl(oas) {
103103
}
104104

105105
function normalizePath(path) {
106-
const curlBacketMatch = /{(.*?)}/;
107-
108-
return path
109-
.split('/')
110-
.map(p => {
111-
const pathMatch = curlBacketMatch.exec(p);
112-
if (pathMatch) return `:${pathMatch[1]}`;
113-
return p;
114-
})
115-
.join('/');
106+
return path.replace(/{(.*?)}/g, ':$1');
116107
}
117108

118109
function generatePathMatches(paths, pathName, origin) {
@@ -204,8 +195,7 @@ class Oas {
204195
return new Operation(this, path, method, operation);
205196
}
206197

207-
findOperation(logInput) {
208-
const { url, method } = logInput.request.log.entries[0].request;
198+
findOperation(url, method) {
209199
const { origin, pathname } = new URL(url);
210200
const { servers, paths } = this;
211201

0 commit comments

Comments
 (0)