diff options
author | John Ahlroos <john@vaadin.com> | 2013-04-23 12:50:09 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2013-04-24 10:28:34 +0000 |
commit | 4a6ed040c7c09ae61f1e3f751c0f1372610bfbc9 (patch) | |
tree | 7e4cd06f0b45cbb25a0d4b81a943c2e6b9d50f00 /theme-compiler | |
parent | dfe27b2deb165501fdceff0a7498ea7332879a93 (diff) | |
download | vaadin-framework-4a6ed040c7c09ae61f1e3f751c0f1372610bfbc9.tar.gz vaadin-framework-4a6ed040c7c09ae61f1e3f751c0f1372610bfbc9.zip |
Fixed failing path resolving when scss compiler is resolving included mixins from classpath #11684
Change-Id: I7943ecb283cca80526fc9b35ff51b698a3b9af6a
Diffstat (limited to 'theme-compiler')
-rw-r--r-- | theme-compiler/src/com/vaadin/sass/internal/resolver/ClassloaderResolver.java | 6 | ||||
-rw-r--r-- | theme-compiler/src/com/vaadin/sass/internal/resolver/VaadinResolver.java | 50 |
2 files changed, 25 insertions, 31 deletions
diff --git a/theme-compiler/src/com/vaadin/sass/internal/resolver/ClassloaderResolver.java b/theme-compiler/src/com/vaadin/sass/internal/resolver/ClassloaderResolver.java index 7ab789ca3f..8711a0a3e9 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/resolver/ClassloaderResolver.java +++ b/theme-compiler/src/com/vaadin/sass/internal/resolver/ClassloaderResolver.java @@ -40,6 +40,12 @@ public class ClassloaderResolver implements ScssStylesheetResolver { // Ensure only "/" is used, also in Windows fileName = fileName.replace(File.separatorChar, '/'); + // Filename should be a relative path starting with VAADIN/... + int vaadinIdx = fileName.lastIndexOf("VAADIN/"); + if (vaadinIdx > -1) { + fileName = fileName.substring(vaadinIdx); + } + // Can the classloader find it? InputStream is = getClass().getClassLoader().getResourceAsStream( fileName); diff --git a/theme-compiler/src/com/vaadin/sass/internal/resolver/VaadinResolver.java b/theme-compiler/src/com/vaadin/sass/internal/resolver/VaadinResolver.java index f51201da06..25c7e04f99 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/resolver/VaadinResolver.java +++ b/theme-compiler/src/com/vaadin/sass/internal/resolver/VaadinResolver.java @@ -15,8 +15,8 @@ */ package com.vaadin.sass.internal.resolver; -import java.util.regex.Matcher; -import java.util.regex.Pattern; +import java.net.URI; +import java.net.URISyntaxException; import org.w3c.css.sac.InputSource; @@ -24,39 +24,27 @@ public class VaadinResolver implements ScssStylesheetResolver { @Override public InputSource resolve(String identifier) { - if (identifier.endsWith(".css")) { - // CSS support mainly for testing, don't load from classpath etc - ScssStylesheetResolver resolver = new FilesystemResolver(); - return resolver.resolve(identifier); + + /* + * Normalize classpath so ../../ segments are resolved + */ + try { + identifier = new URI(identifier).normalize().getPath(); + } catch (URISyntaxException e) { + // No worries, continuing with the unnormalized path and hope for + // the best } InputSource source = null; - - Pattern pattern = Pattern - .compile("\\.\\.\\/([^\\/]+)\\/([^\\/]+\\.scss)"); - Matcher matcher = pattern.matcher(identifier); - - if (matcher.find()) { - // theme include - ScssStylesheetResolver resolver = new FilesystemResolver(); + + // Can we find the scss from the file system? + ScssStylesheetResolver resolver = new FilesystemResolver(); + source = resolver.resolve(identifier); + + if (source == null) { + // How about the classpath? + resolver = new ClassloaderResolver(); source = resolver.resolve(identifier); - - if (source == null) { - String themeName = matcher.group(1); - String fileName = matcher.group(2); - resolver = new ClassloaderResolver(); - String id = "VAADIN/themes/" + themeName + "/" + fileName; - source = resolver.resolve(id); - } - - } else { - ScssStylesheetResolver resolver = new FilesystemResolver(); - source = resolver.resolve(identifier); - - if (source == null) { - resolver = new ClassloaderResolver(); - source = resolver.resolve(identifier); - } } return source; |