Permalink
Browse files

http://stackoverflow.com/q/31068911/157882

  • Loading branch information...
BalusC committed Jun 26, 2015
1 parent f09f88c commit 6cf71238456951cca8f18c7c2458b62ad17d9edc
Showing with 7 additions and 5 deletions.
  1. +7 −5 src/main/java/org/omnifaces/resourcehandler/ResourceIdentifier.java
@@ -37,8 +37,7 @@
*/
public ResourceIdentifier(String resourceIdentifier) {
String[] parts = resourceIdentifier.split(":");
library = (parts.length > 1) ? parts[0] : null;
name = parts[parts.length -1 ];
setLibraryAndName((parts.length > 1) ? parts[0] : null, parts[parts.length - 1]);
}
/**
@@ -47,8 +46,7 @@ public ResourceIdentifier(String resourceIdentifier) {
*/
public ResourceIdentifier(UIComponent componentResource) {
Map<String, Object> attributes = componentResource.getAttributes();
library = (String) attributes.get("library");
name = (String) attributes.get("name");
setLibraryAndName((String) attributes.get("library"), (String) attributes.get("name"));
}
/**
@@ -57,8 +55,12 @@ public ResourceIdentifier(UIComponent componentResource) {
* @param name The resource name.
*/
public ResourceIdentifier(String library, String name) {
setLibraryAndName(library, name);
}
private void setLibraryAndName(String library, String name) {
this.library = library;
this.name = name;
this.name = (name != null) ? name.split("[?#;]", 2)[0] : null; // Split gets rid of query string and path fragment.
}
// Getters --------------------------------------------------------------------------------------------------------

0 comments on commit 6cf7123

Please sign in to comment.