Skip to content

Commit

Permalink
improve rewriteUrl method
Browse files Browse the repository at this point in the history
  • Loading branch information
mat1e committed Jul 28, 2021
1 parent 28b0fb7 commit 5a65cfc
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,21 @@ public class DartJsonProcessor {
*
* @param repository: current repository
* @param urlInput: URL to rewrite
* @return modified URL
* @return modified URL as String
*/
private String rewriteUrl(final Repository repository, String urlInput) {
if(urlInput) {
URI uri = new URI(urlInput)
StringBuilder result = new StringBuilder(repository.getUrl())
result.append(uri.getRawPath())
if(uri.getRawQuery()) {
result.append('?').append(uri.getRawQuery())
}
if(uri.getRawFragment()) {
result.append('#').append(uri.getRawFragment())
}
return result.toString()
URI input = new URI(urlInput)
URI repositoryUrl = new URI(repository.getUrl())
URI output = new URI(
repositoryUrl.scheme,
repositoryUrl.userInfo,
repositoryUrl.host,
repositoryUrl.port,
repositoryUrl.path + input.path,
input.query,
input.fragment)
return output.toURL().toString()
}
return urlInput
}
Expand Down

0 comments on commit 5a65cfc

Please sign in to comment.