aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2015-03-30 16:36:24 +0300
committerJohannes Dahlström <johannesd@vaadin.com>2015-03-30 16:36:24 +0300
commit73c9c8ba75d8b8329a185534d952a6e468fe4b22 (patch)
tree47971d7799eb9093529ea5d95e053b53d255de9b
parent043dca01edf501a05a2e239f00da2bf490de6cf2 (diff)
downloadvaadin-framework-73c9c8ba75d8b8329a185534d952a6e468fe4b22.tar.gz
vaadin-framework-73c9c8ba75d8b8329a185534d952a6e468fe4b22.zip
Support HTTPS, FTP, and FTPS resource URLs in Declarative (#17267)7.4.3
Manually picked to 7.4 from commit b96861c1 in master, also added a test. Change-Id: I415f7409084ea0abd8b22ba3892743e11d503c27
-rw-r--r--server/src/com/vaadin/ui/declarative/converters/DesignResourceConverter.java3
-rw-r--r--server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java19
2 files changed, 21 insertions, 1 deletions
diff --git a/server/src/com/vaadin/ui/declarative/converters/DesignResourceConverter.java b/server/src/com/vaadin/ui/declarative/converters/DesignResourceConverter.java
index 70e46b8e7f..21f20e6403 100644
--- a/server/src/com/vaadin/ui/declarative/converters/DesignResourceConverter.java
+++ b/server/src/com/vaadin/ui/declarative/converters/DesignResourceConverter.java
@@ -39,7 +39,8 @@ public class DesignResourceConverter implements Converter<String, Resource> {
public Resource convertToModel(String value,
Class<? extends Resource> targetType, Locale locale)
throws Converter.ConversionException {
- if (value.startsWith("http://")) {
+ if (value.startsWith("http://") || value.startsWith("https://")
+ || value.startsWith("ftp://") || value.startsWith("ftps://")) {
return new ExternalResource(value);
} else if (value.startsWith("theme://")) {
return new ThemeResource(value.substring(8));
diff --git a/server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java b/server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java
index 05b2484767..9b01188aea 100644
--- a/server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java
+++ b/server/tests/src/com/vaadin/tests/design/DesignFormatterTest.java
@@ -227,6 +227,25 @@ public class DesignFormatterTest {
assertEquals(zone, result);
}
+ @Test
+ public void testExternalResource() {
+ String url = "://example.com/my%20icon.png?a=b";
+
+ for (String scheme : new String[] { "http", "https", "ftp", "ftps" }) {
+ Resource resource = formatter.parse(scheme + url, Resource.class);
+
+ assertTrue(scheme + " url should be parsed as ExternalResource",
+ resource instanceof ExternalResource);
+ assertEquals("parsed ExternalResource", scheme + url,
+ ((ExternalResource) resource).getURL());
+
+ String formatted = formatter.format(new ExternalResource(scheme
+ + url));
+
+ assertEquals("formatted ExternalResource", scheme + url, formatted);
+ }
+ }
+
/**
* A static method to allow comparison two different actions.
*