X-Git-Url: http://dolda2000.com/gitweb/?p=jsvc.git;a=blobdiff_plain;f=src%2Fdolda%2Fjsvc%2Futil%2FStaticContent.java;h=6d74e3795a29cb111c8131122469ca5de9d1423b;hp=685669c09df6077c9df55a8a91793e15c68e6511;hb=e899706d484297f283373f8b55825d2c4e5a067c;hpb=ba5757cbfe4630e795f85fb7f4dc5ff5d684e8c7 diff --git a/src/dolda/jsvc/util/StaticContent.java b/src/dolda/jsvc/util/StaticContent.java index 685669c..6d74e37 100644 --- a/src/dolda/jsvc/util/StaticContent.java +++ b/src/dolda/jsvc/util/StaticContent.java @@ -10,24 +10,22 @@ public class StaticContent implements Responder { private final boolean dir; private final String mimetype; - public StaticContent(Class base, String resname, boolean dir, String mimetype) { + public StaticContent(Class base, String resname, String mimetype) { this.base = base; - this.resname = resname; - this.dir = dir; + this.dir = ((this.resname = resname).charAt(resname.length() - 1) == '/'); this.mimetype = mimetype; } - public StaticContent(String resname, boolean dir, String mimetype) { - this(null, resname, dir, mimetype); + public StaticContent(String resname, String mimetype) { + this(null, resname, mimetype); } public void respond(Request req) { String nm; - if(dir) { - nm = resname + "/" + req.path(); - } else { + if(dir) + nm = resname + req.path(); + else nm = resname; - } InputStream in; if(base == null) { in = StaticContent.class.getClassLoader().getResourceAsStream(nm);