From 0f5a97b53989afcfc835a388d539024a20e30f49 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sun, 31 Mar 2024 15:59:30 +0100 Subject: [PATCH] Improve repo and forum topic matching in hints --- app/public/static/js/package_edit.js | 5 +++-- app/templates/packages/create_edit.html | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/public/static/js/package_edit.js b/app/public/static/js/package_edit.js index 0701171a..fac8f678 100644 --- a/app/public/static/js/package_edit.js +++ b/app/public/static/js/package_edit.js @@ -84,10 +84,11 @@ window.addEventListener("load", () => { }, "desc_page_topic": (val) => { const topicId = document.getElementById("forums").value; - return topicId && val.indexOf(`forum.minetest.net/viewtopic.php?t=${topicId}`) >= 0; + const r = new RegExp(`forum\\.minetest\\.net\\/viewtopic\\.php\\?[a-z0-9=&]*t=${topicId}`); + return topicId && r.test(val); }, "desc_page_repo": (val) => { - const repoUrl = document.getElementById("repo").value; + const repoUrl = document.getElementById("repo").value.replace(".git", ""); return repoUrl && val.indexOf(repoUrl.toLowerCase()) >= 0; }, }); diff --git a/app/templates/packages/create_edit.html b/app/templates/packages/create_edit.html index 201260d9..7639015d 100644 --- a/app/templates/packages/create_edit.html +++ b/app/templates/packages/create_edit.html @@ -21,7 +21,7 @@ {% endif %} - + {% endblock %} {% block content %}