From b12a3311866fb2a1aa0bf65fbae006eb82310612 Mon Sep 17 00:00:00 2001 From: Yahav Itschak Date: Sun, 21 Jul 2024 11:51:50 +0300 Subject: [PATCH] Support No-Proxy hosts with dash (#97) --- .../jfrog/configuration/JenkinsProxyConfiguration.java | 2 +- .../jfrog/configuration/JenkinsProxyConfigurationTest.java | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/jenkins/plugins/jfrog/configuration/JenkinsProxyConfiguration.java b/src/main/java/io/jenkins/plugins/jfrog/configuration/JenkinsProxyConfiguration.java index ebfea0f1..90e73061 100644 --- a/src/main/java/io/jenkins/plugins/jfrog/configuration/JenkinsProxyConfiguration.java +++ b/src/main/java/io/jenkins/plugins/jfrog/configuration/JenkinsProxyConfiguration.java @@ -15,7 +15,7 @@ * Because of the Jenkins.get() used in the constructor, you can only create it on the master, not on an agent. */ public class JenkinsProxyConfiguration extends ProxyConfiguration { - private static final Pattern HOST_NAME_PATTERN = Pattern.compile("^.*?://?([\\w.]+).*"); + private static final Pattern HOST_NAME_PATTERN = Pattern.compile("^.*?://?([\\w.-]+).*"); public List noProxyHostPatterns; public String noProxy; diff --git a/src/test/java/io/jenkins/plugins/jfrog/configuration/JenkinsProxyConfigurationTest.java b/src/test/java/io/jenkins/plugins/jfrog/configuration/JenkinsProxyConfigurationTest.java index f329edff..f3f5d744 100644 --- a/src/test/java/io/jenkins/plugins/jfrog/configuration/JenkinsProxyConfigurationTest.java +++ b/src/test/java/io/jenkins/plugins/jfrog/configuration/JenkinsProxyConfigurationTest.java @@ -1,6 +1,7 @@ package io.jenkins.plugins.jfrog.configuration; import jenkins.model.Jenkins; +import org.apache.commons.lang3.StringUtils; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -63,6 +64,10 @@ public void testShouldBypassProxy() { setupProxy("acme.jfrog.info"); assertFalse(new JenkinsProxyConfiguration().shouldBypassProxy(url)); + + setupProxy("acme.jfrog.io-dashed"); + String dashedUrl = StringUtils.replace(url, "acme.jfrog.io", "acme.jfrog.io-dashed"); + assertTrue(new JenkinsProxyConfiguration().shouldBypassProxy(dashedUrl)); } private void setupProxy(String noProxyHost) {