Skip to content
This repository was archived by the owner on Jun 9, 2021. It is now read-only.

Commit 6532327

Browse files
authored
Merge pull request #271 from jwoolston/issue-229-development
#229 Proposed URI reconstruction to remove username from PULL_REQUEST…
2 parents d8b1d48 + 8b3d22b commit 6532327

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/main/java/se/bjurr/prnfb/service/PrnfbVariable.java

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
import static se.bjurr.prnfb.service.RepoProtocol.http;
1616
import static se.bjurr.prnfb.service.RepoProtocol.ssh;
1717

18+
import java.net.URI;
19+
import java.net.URISyntaxException;
1820
import java.util.Collections;
1921
import java.util.Iterator;
2022
import java.util.List;
@@ -1362,7 +1364,26 @@ public String perform() throws RuntimeException {
13621364
if (allUrls.isEmpty()) {
13631365
return "";
13641366
}
1365-
return allUrls.iterator().next();
1367+
final String rawUrlString = allUrls.iterator().next();
1368+
try {
1369+
final URI uri = new URI(rawUrlString);
1370+
if (uri.getUserInfo() == null) {
1371+
return rawUrlString;
1372+
} else {
1373+
final URI stripped =
1374+
new URI(
1375+
uri.getScheme(),
1376+
null,
1377+
uri.getHost(),
1378+
uri.getPort(),
1379+
uri.getPath(),
1380+
uri.getQuery(),
1381+
uri.getFragment());
1382+
return stripped.toASCIIString();
1383+
}
1384+
} catch (NullPointerException | URISyntaxException e) {
1385+
throw new RuntimeException(e);
1386+
}
13661387
}
13671388
});
13681389
}

0 commit comments

Comments
 (0)