瀏覽代碼

fixed loadResource if url is a directory

Nicolas Cannasse 5 月之前
父節點
當前提交
9f8801cf6e
共有 1 個文件被更改,包括 7 次插入1 次删除
  1. 7 1
      h2d/domkit/BaseComponents.hx

+ 7 - 1
h2d/domkit/BaseComponents.hx

@@ -69,7 +69,13 @@ class CustomParser extends domkit.CssValue.ValueParser {
 		// TODO : compile-time path check?
 		return true;
 		#else
-		return try hxd.res.Loader.currentInstance.load(path) catch( e : hxd.res.NotFound ) invalidProp("Resource not found "+path);
+		return try {
+			var f = hxd.res.Loader.currentInstance.load(path);
+			if( f.entry.isDirectory ) invalidProp("Resource should be a file "+path);
+			return f;
+		} catch( e : hxd.res.NotFound ) {
+			invalidProp("Resource not found "+path);
+		}
 		#end
 	}