You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2021/11/25 18:31:58 UTC

[commons-vfs] 03/04: Reduce duplication.

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git

commit 78785196e1cdea917c3fff3af4c31ab5ffc35386
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Nov 25 13:31:18 2021 -0500

    Reduce duplication.
---
 .../org/apache/commons/vfs2/provider/http4/Http4FileSystem.java   | 8 ++------
 .../org/apache/commons/vfs2/provider/http5/Http5FileSystem.java   | 8 ++------
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileSystem.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileSystem.java
index 9747232..85aa472 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileSystem.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http4/Http4FileSystem.java
@@ -69,12 +69,8 @@ public class Http4FileSystem extends AbstractFileSystem {
         final char lastCharOfScheme = offset > 0 ? rootURI.charAt(offset - 1) : 0;
 
         // if scheme is 'http*s' or 'HTTP*S', then the internal base URI should be 'https'. 'http' otherwise.
-        if (lastCharOfScheme == 's' || lastCharOfScheme == 'S') {
-            this.internalBaseURI = URI.create("https" + rootURI.substring(offset));
-        } else {
-            this.internalBaseURI = URI.create("http" + rootURI.substring(offset));
-        }
-
+        final String scheme  = lastCharOfScheme == 's' || lastCharOfScheme == 'S' ? "https" : "http";
+        this.internalBaseURI = URI.create(scheme + rootURI.substring(offset));
         this.httpClient = httpClient;
         this.httpClientContext = httpClientContext;
     }
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileSystem.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileSystem.java
index 758024d..63b7c36 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileSystem.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/http5/Http5FileSystem.java
@@ -69,12 +69,8 @@ public class Http5FileSystem extends AbstractFileSystem {
         final char lastCharOfScheme = offset > 0 ? rootURI.charAt(offset - 1) : 0;
 
         // if scheme is 'http*s' or 'HTTP*S', then the internal base URI should be 'https'. 'http' otherwise.
-        if (lastCharOfScheme == 's' || lastCharOfScheme == 'S') {
-            this.internalBaseURI = URI.create("https" + rootURI.substring(offset));
-        } else {
-            this.internalBaseURI = URI.create("http" + rootURI.substring(offset));
-        }
-
+        final String scheme  = lastCharOfScheme == 's' || lastCharOfScheme == 'S' ? "https" : "http";
+        this.internalBaseURI = URI.create(scheme + rootURI.substring(offset));
         this.httpClient = httpClient;
         this.httpClientContext = httpClientContext;
     }