Skip to content

Commit

Permalink
Support No-Proxy hosts with dash (#97)
Browse files Browse the repository at this point in the history
  • Loading branch information
yahavi authored Jul 21, 2024
1 parent 9f46764 commit b12a331
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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<Pattern> noProxyHostPatterns;
public String noProxy;

Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit b12a331

Please sign in to comment.