@@ -22,10 +22,10 @@ public class MinifyHtml {
2222 throw new RuntimeException (String .format ("Platform not supported (os.name=%s, os.arch=%s)" , osName , osArch ));
2323 }
2424
25- final String nativeLibFile = String .format ("/ %s-%s.nativelib" , nativeLibNameOs , nativeLibNameArch );
25+ final String nativeLibFile = String .format ("%s-%s.nativelib" , nativeLibNameOs , nativeLibNameArch );
2626
27- try (InputStream is = MinifyHtml .class .getResourceAsStream (nativeLibFile )) {
28- final File temp = File .createTempFile ("minify-html-java-nativelib" , nativeLibFile . substring ( 1 ) );
27+ try (InputStream is = MinifyHtml .class .getResourceAsStream ("/" + nativeLibFile )) {
28+ final File temp = File .createTempFile ("minify-html-java-nativelib" , nativeLibFile );
2929 temp .deleteOnExit ();
3030 Files .copy (is , temp .toPath (), StandardCopyOption .REPLACE_EXISTING );
3131 System .load (temp .getAbsolutePath ());
@@ -41,11 +41,22 @@ private MinifyHtml() {
4141 * Minify HTML code represented as a {@link String}.
4242 * The {@link String} will be copied to a UTF-8 byte array in native code, and then copied back into a Java {@link String}.
4343 *
44- * @param code HTML code to minify
45- * @param cfg {@link Configuration} minification settings to use
44+ * @param code HTML code to minify, cannot be null
45+ * @param cfg {@link Configuration} minification settings to use, cannot be null
4646 * @return minified HTML code
47+ * @throws IllegalArgumentException if either {@code code} or {@code cfg} is null
4748 */
48- public static native String minify (String code , Configuration cfg );
49+ public static String minify (String code , Configuration cfg ) {
50+ if (code == null ) {
51+ throw new IllegalArgumentException ("code cannot be null" );
52+ }
53+ if (cfg == null ) {
54+ throw new IllegalArgumentException ("configuration cannot be null" );
55+ }
56+ return minifyRs (code , cfg );
57+ }
58+
59+ private static native String minifyRs (String code , Configuration cfg );
4960
5061 private static String getNativeLibNameOs (String osName ) {
5162 if (osName .startsWith ("windows" )) {
0 commit comments