Fix user agent version check

Make sure that any additional information is not associated to the
version.
This commit is contained in:
Stephane Nicoll 2016-02-09 11:21:49 +01:00
parent de256e9caf
commit caaa13a629
2 changed files with 12 additions and 1 deletions

View File

@ -26,7 +26,7 @@ import org.springframework.util.Assert
*/ */
class UserAgentWrapper { class UserAgentWrapper {
private static final TOOL_REGEX = '(.*)\\/(.*)' private static final TOOL_REGEX = '([^\\/]*)\\/([^ ]*).*'
private static final STS_REGEX = 'STS (.*)' private static final STS_REGEX = 'STS (.*)'

View File

@ -83,6 +83,17 @@ class UserAgentWrapperTests {
assertThat(information.version, is(nullValue())) assertThat(information.version, is(nullValue()))
} }
@Test
void checkIntelliJIDEAWithVersion() {
UserAgentWrapper userAgent = new UserAgentWrapper('IntelliJ IDEA/144.2 (Community edition; en-us)')
assertThat(userAgent.isCurl(), is(false))
assertThat(userAgent.isHttpie(), is(false))
assertThat(userAgent.isSpringBootCli(), is(false))
def information = userAgent.extractAgentInformation()
assertThat(information.id, equalTo(UserAgentWrapper.AgentId.INTELLIJ_IDEA))
assertThat(information.version, is('144.2'))
}
@Test @Test
void checkGenericBrowser() { void checkGenericBrowser() {
UserAgentWrapper userAgent = UserAgentWrapper userAgent =