+ // Check the domain status.
+ return checkDomain(urlRequestInfo, urlStruct, requestStructPointer, filterListTitle, sublistInt, entryStructPointer);
+ }
+ }
+ }
+ else // There are multiple entries.
+ {
+ // Create a URL matches flag.
+ bool urlMatches = true;
+
+ // Process initial and final matches.
+ if (entryStructPointer->initialMatch && entryStructPointer->finalMatch) // This is both an initial and final match.
+ {
+ // Check the first entry.
+ if (urlString.startsWith(entryStructPointer->appliedEntryList[0]) ||
+ urlStringWithSeparators.startsWith(entryStructPointer->appliedEntryList[0])) // The URL string starts with the first applied entry.
+ {
+ // Get the number of characters to remove from the front of the URL strings.
+ int charactersToRemove = entryStructPointer->appliedEntryList[0].size();
+
+ // Remove the entry from the front of the URL string copies.
+ urlString.remove(0, charactersToRemove);
+ urlStringWithSeparators.remove(0, charactersToRemove);
+ }
+ else // The URL string does not end with the last applied entry.
+ {
+ // Mark the URL matches flag as false.
+ urlMatches = false;
+ }
+
+ // Check the other entries if the URL still matches.
+ if (urlMatches)
+ {
+ // Calculate the penultimate entry.
+ int penultimateEntryNumber = (entryStructPointer->sizeOfAppliedEntryList - 1);
+ int ultimateEntryIndex = penultimateEntryNumber;
+
+ // Check all the middle entries.
+ for (int i = 1; i < penultimateEntryNumber; ++i)
+ {
+ // Get the index of the applied entry, which will be `-1` if it doesn't exist.
+ int stringIndex = urlString.indexOf(entryStructPointer->appliedEntryList[i]);
+ int stringWithSeparatorsIndex = urlStringWithSeparators.indexOf(entryStructPointer->appliedEntryList[i]);
+
+ // Get the larger of the two indexes.
+ int index = std::max(stringIndex, stringWithSeparatorsIndex);
+
+ // Check if the entry was found.
+ if (index >= 0) // The entry is contained in the URL string.
+ {
+ // Get the number of characters to remove from the front of the URL strings.
+ int charactersToRemove = index + entryStructPointer->appliedEntryList[i].size();
+
+ // Remove the entry from the front of the URL string copies.
+ urlString.remove(0, charactersToRemove);
+ urlStringWithSeparators.remove(0, charactersToRemove);
+ }
+ else // The entry is not contained in the URL string.
+ {
+ // Mark the URL matches flag as false.
+ urlMatches = false;
+ }
+ }
+
+ // Check the final entry if the URL still matches.
+ if (urlMatches)
+ {
+ if (urlString.endsWith(entryStructPointer->appliedEntryList[ultimateEntryIndex]) ||
+ urlStringWithSeparators.endsWith(entryStructPointer->appliedEntryList[ultimateEntryIndex])) // The URL string ends with the last applied entry.
+ {
+ // There is no need to modify the URL string copies as no further checks will be performed.
+ }
+ else // The URL string does not end with the last applied entry.
+ {
+ // Mark the URL matches flag as false.
+ urlMatches = false;
+ }
+ }
+ }
+ }
+ else if (entryStructPointer->initialMatch) // This is an initial match.
+ {
+ // Check the first entry.
+ if (urlString.startsWith(entryStructPointer->appliedEntryList[0]) ||
+ urlStringWithSeparators.startsWith(entryStructPointer->appliedEntryList[0])) // The URL string starts with the first applied entry.
+ {
+ // Get the number of characters to remove from the front of the URL strings.
+ int charactersToRemove = entryStructPointer->appliedEntryList[0].size();
+
+ // Remove the entry from the front of the URL string copies.
+ urlString.remove(0, charactersToRemove);
+ urlStringWithSeparators.remove(0, charactersToRemove);
+ }
+ else // The URL string does not end with the last applied entry.
+ {
+ // Mark the URL matches flag as false.
+ urlMatches = false;
+ }
+
+ // Check the other entries if the URL still matches.
+ if (urlMatches)
+ {
+ for (int i = 1; i < entryStructPointer->sizeOfAppliedEntryList; ++i)
+ {
+ // Get the index of the applied entry, which will be `-1` if it doesn't exist.
+ int stringIndex = urlString.indexOf(entryStructPointer->appliedEntryList[i]);
+ int stringWithSeparatorsIndex = urlStringWithSeparators.indexOf(entryStructPointer->appliedEntryList[i]);
+
+ // Get the larger of the two indexes.
+ int index = std::max(stringIndex, stringWithSeparatorsIndex);
+
+ // Check if the entry was found.
+ if (index >= 0) // The entry is contained in the URL string.
+ {
+ // Get the number of characters to remove from the front of the URL strings.
+ int charactersToRemove = index + entryStructPointer->appliedEntryList[i].size();
+
+ // Remove the entry from the front of the URL string copies.
+ urlString.remove(0, charactersToRemove);
+ urlStringWithSeparators.remove(0, charactersToRemove);
+ }
+ else // The entry is not contained in the URL string.
+ {
+ // Mark the URL matches flag as false.
+ urlMatches = false;
+ }
+ }
+ }
+ }
+ else if (entryStructPointer->finalMatch) // This is a final match.
+ {
+ // Calculate the penultimate entry.
+ int penultimateEntryNumber = (entryStructPointer->sizeOfAppliedEntryList - 1);
+ int ultimateEntryIndex = penultimateEntryNumber;
+
+ // Check all the entries except the last one.
+ for (int i = 0; i < penultimateEntryNumber; ++i)
+ {
+ // Get the index of the applied entry, which will be `-1` if it doesn't exist.
+ int stringIndex = urlString.indexOf(entryStructPointer->appliedEntryList[i]);
+ int stringWithSeparatorsIndex = urlStringWithSeparators.indexOf(entryStructPointer->appliedEntryList[i]);
+
+ // Get the larger of the two indexes.
+ int index = std::max(stringIndex, stringWithSeparatorsIndex);
+
+ // Check if the entry was found.
+ if (index >= 0) // The entry is contained in the URL string.
+ {
+ // Get the number of characters to remove from the front of the URL strings.
+ int charactersToRemove = index + entryStructPointer->appliedEntryList[i].size();
+
+ // Remove the entry from the front of the URL string copies.
+ urlString.remove(0, charactersToRemove);
+ urlStringWithSeparators.remove(0, charactersToRemove);
+ }
+ else // The entry is not contained in the URL string.
+ {
+ // Mark the URL matches flag as false.
+ urlMatches = false;
+ }
+ }