From e1ce384815dcf7709a6ee8f84a052ed5acf026e5 Mon Sep 17 00:00:00 2001 From: TopchetoEU <36534413+TopchetoEU@users.noreply.github.com> Date: Sat, 25 Nov 2023 18:44:27 +0200 Subject: [PATCH] feat: add parse function to Filename --- src/me/topchetoeu/jscript/Filename.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/me/topchetoeu/jscript/Filename.java b/src/me/topchetoeu/jscript/Filename.java index 8e87ef6..3138887 100644 --- a/src/me/topchetoeu/jscript/Filename.java +++ b/src/me/topchetoeu/jscript/Filename.java @@ -51,4 +51,10 @@ public class Filename { this.protocol = protocol; this.path = path; } + + public static Filename parse(String val) { + var i = val.indexOf("://"); + if (i >= 0) return new Filename(val.substring(0, i).trim(), val.substring(i + 3).trim()); + else return new Filename("file", val.trim()); + } }