mirror of
https://gitee.com/dcren/initializr.git
synced 2025-05-09 15:18:02 +08:00
Fix user agent version check
Make sure that any additional information is not associated to the version.
This commit is contained in:
parent
de256e9caf
commit
caaa13a629
@ -26,7 +26,7 @@ import org.springframework.util.Assert
|
||||
*/
|
||||
class UserAgentWrapper {
|
||||
|
||||
private static final TOOL_REGEX = '(.*)\\/(.*)'
|
||||
private static final TOOL_REGEX = '([^\\/]*)\\/([^ ]*).*'
|
||||
|
||||
private static final STS_REGEX = 'STS (.*)'
|
||||
|
||||
|
@ -83,6 +83,17 @@ class UserAgentWrapperTests {
|
||||
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
|
||||
void checkGenericBrowser() {
|
||||
UserAgentWrapper userAgent =
|
||||
|
Loading…
Reference in New Issue
Block a user