Skip to content

Commit

Permalink
Minor improvements suggested by @dok in PR comments:
Browse files Browse the repository at this point in the history
- More robust regex for path matching
- findOperation more agnostic
  • Loading branch information
gratcliff committed Jan 22, 2020
1 parent 701ef96 commit 5a5469c
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/oas.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,7 @@ function normalizedUrl(oas) {
}

function normalizePath(path) {
const curlBacketMatch = /{(.*?)}/;

return path
.split('/')
.map(p => {
const pathMatch = curlBacketMatch.exec(p);
if (pathMatch) return `:${pathMatch[1]}`;
return p;
})
.join('/');
return path.replace(/{(.*?)}/g, ':$1');
}

function generatePathMatches(paths, pathName, origin) {
Expand Down Expand Up @@ -204,8 +195,7 @@ class Oas {
return new Operation(this, path, method, operation);
}

findOperation(logInput) {
const { url, method } = logInput.request.log.entries[0].request;
findOperation(url, method) {
const { origin, pathname } = new URL(url);
const { servers, paths } = this;

Expand Down

0 comments on commit 5a5469c

Please sign in to comment.