From a77be682a7317b2f6a06a724b45316671301888a Mon Sep 17 00:00:00 2001 From: CMEONE Date: Thu, 4 Mar 2021 10:10:22 -0800 Subject: [PATCH] Add path checker and errors --- tApp.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tApp.js b/tApp.js index 9f334fb..3ae793d 100644 --- a/tApp.js +++ b/tApp.js @@ -4,7 +4,7 @@ class tApp { static cache = {}; static cacheSize = 0; static get version() { - return "v0.2.0"; + return "v0.2.1"; } static configure(params) { if(params == null) { @@ -69,7 +69,11 @@ class tApp { }; } static route(path, renderFunction) { - tApp.routes[path] = renderFunction; + if(path == "/" || path.substring(0, 1) == "#") { + tApp.routes[path] = renderFunction; + } else { + throw "tAppError: Invalid path, the path can only be \"/\" or start with \"#\"."; + } } static get(path) { return new Promise((resolve, reject) => {