diff --git a/static/js/code.js b/static/js/code.js index 4115938..f6ccf53 100644 --- a/static/js/code.js +++ b/static/js/code.js @@ -79,3 +79,14 @@ const ConfirmDelete = async (table, obj_id) => { return false; } } + +const UrlId = () => { + let url = new URL(window.location.href); + let parts = url.pathname.split("/"); + + if(window.location.href.endsWith("/")) { + return parts[parts.length - 2]; + } else { + return parts[parts.length - 1]; + } +} diff --git a/views/post/view.html b/views/post/view.html index e8bcbf5..f72007e 100644 --- a/views/post/view.html +++ b/views/post/view.html @@ -1,7 +1,7 @@ + x-init="item = await GetJson('/api/message/' + UrlId())">