Improve repo and forum topic matching in hints

This commit is contained in:
rubenwardy 2024-03-31 15:59:30 +01:00
parent 792488cce1
commit 0f5a97b539
2 changed files with 4 additions and 3 deletions

@ -84,10 +84,11 @@ window.addEventListener("load", () => {
}, },
"desc_page_topic": (val) => { "desc_page_topic": (val) => {
const topicId = document.getElementById("forums").value; 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) => { "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; return repoUrl && val.indexOf(repoUrl.toLowerCase()) >= 0;
}, },
}); });

@ -21,7 +21,7 @@
<script src="/static/js/polltask.js"></script> <script src="/static/js/polltask.js"></script>
<script src="/static/js/package_create.js"></script> <script src="/static/js/package_create.js"></script>
{% endif %} {% endif %}
<script src="/static/js/package_edit.js?v=2"></script> <script src="/static/js/package_edit.js?v=3"></script>
{% endblock %} {% endblock %}
{% block content %} {% block content %}