mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2026-01-01 13:18:06 -06:00
WebUI: use idiomatic string methods
This commit is contained in:
@@ -1492,7 +1492,7 @@ window.addEventListener("DOMContentLoaded", () => {
|
||||
const handleDownloadParam = () => {
|
||||
// Extract torrent URL from download param in WebUI URL hash
|
||||
const downloadHash = "#download=";
|
||||
if (location.hash.indexOf(downloadHash) !== 0)
|
||||
if (!location.hash.startsWith(downloadHash))
|
||||
return;
|
||||
|
||||
const url = decodeURIComponent(location.hash.substring(downloadHash.length));
|
||||
|
||||
@@ -255,8 +255,8 @@ window.qBittorrent.Misc ??= (() => {
|
||||
const containsAllTerms = (text, terms) => {
|
||||
const textToSearch = text.toLowerCase();
|
||||
return terms.every((term) => {
|
||||
const isTermRequired = (term[0] === "+");
|
||||
const isTermExcluded = (term[0] === "-");
|
||||
const isTermRequired = term.startsWith("+");
|
||||
const isTermExcluded = term.startsWith("-");
|
||||
if (isTermRequired || isTermExcluded) {
|
||||
// ignore lonely +/-
|
||||
if (term.length === 1)
|
||||
@@ -265,7 +265,7 @@ window.qBittorrent.Misc ??= (() => {
|
||||
term = term.substring(1);
|
||||
}
|
||||
|
||||
const textContainsTerm = (textToSearch.indexOf(term) !== -1);
|
||||
const textContainsTerm = textToSearch.includes(term);
|
||||
return isTermExcluded ? !textContainsTerm : textContainsTerm;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -146,7 +146,7 @@ window.qBittorrent.PropTrackers ??= (() => {
|
||||
onShow: function() {
|
||||
const selectedTrackers = torrentTrackersTable.selectedRowsIds();
|
||||
const containsStaticTracker = selectedTrackers.some((tracker) => {
|
||||
return (tracker.indexOf("** [") === 0);
|
||||
return tracker.startsWith("** [");
|
||||
});
|
||||
|
||||
if (containsStaticTracker || (selectedTrackers.length === 0)) {
|
||||
|
||||
Reference in New Issue
Block a user