From 87e0325a2aeb7aec9dbda2f850b7904acbbf29be Mon Sep 17 00:00:00 2001 From: Nikolay Demyankov Date: Tue, 30 Aug 2016 10:41:58 +0200 Subject: [PATCH] Files can now have spaces in their names on Android: https://github.com/nordnet/cordova-hot-code-push/issues/197 --- .../src/com/nordnetab/chcp/main/utils/URLUtility.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/android/src/com/nordnetab/chcp/main/utils/URLUtility.java b/src/android/src/com/nordnetab/chcp/main/utils/URLUtility.java index 26a65296..b114afa9 100644 --- a/src/android/src/com/nordnetab/chcp/main/utils/URLUtility.java +++ b/src/android/src/com/nordnetab/chcp/main/utils/URLUtility.java @@ -1,6 +1,9 @@ package com.nordnetab.chcp.main.utils; +import android.util.Log; + import java.net.MalformedURLException; +import java.net.URI; import java.net.URL; import java.net.URLDecoder; @@ -21,12 +24,14 @@ public class URLUtility { public static URL stringToUrl(String urlString) { URL url = null; try { - url = new URL(URLDecoder.decode(urlString, "UTF-8")); + url = new URL(urlString); + final URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); + url = uri.toURL(); } catch (Exception e) { try { url = new URL(urlString); } catch (MalformedURLException e2) { - e2.printStackTrace(); + Log.d("CHCP", "Failed to transfer url string \"" + urlString + "\" to actual url", e2); } }