mirror of
https://github.com/StuffAnThings/qbit_manage.git
synced 2025-10-09 13:29:15 +08:00
refactor(ui): separate HTTP and HTTPS URL regex handling in log viewer
Split the single URL regex into two separate patterns for HTTP and HTTPS to improve code clarity and maintainability, while preserving identical link generation behavior. [FR]: WebUI make hyperlinks clickable Fixes #938
This commit is contained in:
parent
2f3319ddab
commit
ce8a418d4b
2 changed files with 12 additions and 5 deletions
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
4.6.1-develop15
|
4.6.1-develop16
|
||||||
|
|
|
@ -318,16 +318,23 @@ class LogViewer {
|
||||||
* @returns {string} - HTML with clickable links
|
* @returns {string} - HTML with clickable links
|
||||||
*/
|
*/
|
||||||
makeLinksClickable(text) {
|
makeLinksClickable(text) {
|
||||||
// URL regex pattern that matches http:// and https:// URLs
|
// URL regex patterns for both HTTP and HTTPS - handled identically
|
||||||
const urlRegex = /(https?:\/\/[^\s]+)/g;
|
const httpRegex = /(http:\/\/[^\s]+)/g;
|
||||||
|
const httpsRegex = /(https:\/\/[^\s]+)/g;
|
||||||
|
|
||||||
// Escape the entire text first for security
|
// Escape the entire text first for security
|
||||||
const escapedText = this.escapeHtml(text);
|
const escapedText = this.escapeHtml(text);
|
||||||
|
|
||||||
// Replace URLs with clickable links
|
// Replace both HTTP and HTTPS URLs with identical clickable links
|
||||||
return escapedText.replace(urlRegex, (url) => {
|
let result = escapedText.replace(httpRegex, (url) => {
|
||||||
return `<a href="${url}" target="_blank" rel="noopener noreferrer" class="log-link">${url}</a>`;
|
return `<a href="${url}" target="_blank" rel="noopener noreferrer" class="log-link">${url}</a>`;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
result = result.replace(httpsRegex, (url) => {
|
||||||
|
return `<a href="${url}" target="_blank" rel="noopener noreferrer" class="log-link">${url}</a>`;
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollToTop() {
|
scrollToTop() {
|
||||||
|
|
Loading…
Add table
Reference in a new issue