mirror of
https://gitee.com/dcren/initializr.git
synced 2025-07-15 14:04:30 +08:00
Add support for NetBeans agent
Closes gh-290
This commit is contained in:
parent
ddf3686612
commit
99fbe8a5ad
@ -63,6 +63,8 @@ class Agent {
|
||||
|
||||
INTELLIJ_IDEA('intellijidea', 'IntelliJ IDEA'),
|
||||
|
||||
NETBEANS('netbeans', 'NetBeans'),
|
||||
|
||||
BROWSER('browser', 'Browser')
|
||||
|
||||
final String id
|
||||
@ -80,6 +82,8 @@ class Agent {
|
||||
|
||||
private static final STS_REGEX = 'STS (.*)'
|
||||
|
||||
private static final NETBEANS_REGEX = 'nb-springboot-plugin\\/(.*)'
|
||||
|
||||
static Agent parse(String userAgent) {
|
||||
def matcher = (userAgent =~ TOOL_REGEX)
|
||||
if (matcher.matches()) {
|
||||
@ -95,6 +99,11 @@ class Agent {
|
||||
if (matcher.matches()) {
|
||||
return new Agent(AgentId.STS, matcher.group(1))
|
||||
}
|
||||
matcher = userAgent =~ NETBEANS_REGEX
|
||||
if (matcher.matches()) {
|
||||
return new Agent(AgentId.NETBEANS, matcher.group(1))
|
||||
}
|
||||
|
||||
if (userAgent.equals(AgentId.INTELLIJ_IDEA.name)) {
|
||||
return new Agent(AgentId.INTELLIJ_IDEA, null)
|
||||
}
|
||||
|
@ -72,6 +72,13 @@ class AgentTests {
|
||||
assertThat(agent.version, is('144.2'))
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkNetBeans() {
|
||||
Agent agent = Agent.fromUserAgent('nb-springboot-plugin/0.1')
|
||||
assertThat(agent.id, equalTo(Agent.AgentId.NETBEANS))
|
||||
assertThat(agent.version, is('0.1'))
|
||||
}
|
||||
|
||||
@Test
|
||||
void checkGenericBrowser() {
|
||||
Agent agent = Agent.fromUserAgent(
|
||||
|
Loading…
Reference in New Issue
Block a user