mirror of
https://github.com/StuffAnThings/qbit_manage.git
synced 2025-10-07 20:40:28 +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
|
||||
*/
|
||||
makeLinksClickable(text) {
|
||||
// URL regex pattern that matches http:// and https:// URLs
|
||||
const urlRegex = /(https?:\/\/[^\s]+)/g;
|
||||
// URL regex patterns for both HTTP and HTTPS - handled identically
|
||||
const httpRegex = /(http:\/\/[^\s]+)/g;
|
||||
const httpsRegex = /(https:\/\/[^\s]+)/g;
|
||||
|
||||
// Escape the entire text first for security
|
||||
const escapedText = this.escapeHtml(text);
|
||||
|
||||
// Replace URLs with clickable links
|
||||
return escapedText.replace(urlRegex, (url) => {
|
||||
// Replace both HTTP and HTTPS URLs with identical clickable links
|
||||
let result = escapedText.replace(httpRegex, (url) => {
|
||||
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() {
|
||||
|
|
Loading…
Add table
Reference in a new issue