Handle leading slash (#1)

* Handle leading slash
This commit is contained in:
piotrekfus91 2018-01-28 18:30:50 +01:00 committed by Dominik Przybysz
parent 6036bd2c3b
commit f8e0cc44f9
3 changed files with 40 additions and 1 deletions

View file

@ -41,10 +41,18 @@ class Mock implements Comparable<Mock> {
throw new RuntimeException("Mock name must be given")
}
this.name = name
this.path = path
this.path = stripLeadingSlash(path)
this.port = port
}
private static String stripLeadingSlash(String path) {
if (path?.startsWith('/')) {
return path - '/'
} else {
return path
}
}
boolean match(Method method, MockRequest request) {
return this.method == method && predicate(request)
}