Add .toUpperCase() after referrer. This method turns the string into an upper case string. Then, use .indexOf() using RAL instead of Ral.

if (referrer.toUpperCase().indexOf("RAL") === -1) { 

The same can also be achieved using a Regular Expression (especially useful when you want to test against dynamic patterns):

if (!/Ral/i.test(referrer)) {
   //    ^i = Ignore case flag for RegExp
Answer from Rob W on Stack Overflow
🌐
Mastering JS
masteringjs.io › tutorials › fundamentals › contains-substring
Check if a String Contains a Substring in JavaScript - Mastering JS
const str = 'arya stark'; // The most concise way to check substrings ignoring case is using // `String#match()` and a case-insensitive regular expression (the 'i') str.match(/Stark/i); // true str.match(/Snow/i); // false // You can also convert ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › String › includes
String.prototype.includes() - JavaScript | MDN
This method lets you determine whether or not a string includes another string. The includes() method is case sensitive.
🌐
30 Seconds of Code
30secondsofcode.org › home › javascript › string › case-insensitive substring search
Can I check if a JavaScript string contains a substring, regardless of case? - 30 seconds of code
May 25, 2024 - As with most languages, JavaScript's substring matching is case-sensitive by default. If you need to check if a string contains a substring, but you don't care about the case, you'll need to roll up your own solution.
🌐
Bobby Hadz
bobbyhadz.com › blog › javascript-includes-case-insensitive
Make includes() case insensitive in JavaScript | bobbyhadz
To make the String.includes() method case insensitive, convert both of the strings in the comparison to lowercase.
🌐
Excessivelyadequate
excessivelyadequate.com › posts › mark.html
Case-insensitive Search Term Highlighting With JavaScript
Unrelated to functionally-correct highlighting but important nonetheless, adding content to a page by setting an element’s .innerHTML property to a value containing bits of straight user input opens the door to code injection. Despite this not6 being exploitable here, I’ll get back to it after addressing 1 & 2. JavaScript’s String.split() function can – instead of a string to split on – also accept a regular expression where each match then yields a split. And, conveniently, JavaScript’s regular expression objects can be created with a case insensitivity flag.
🌐
SheCodes
shecodes.io › athena › 37854-how-to-ignore-case-in-javascript
[JavaScript] - How to ignore case in JavaScript? - SheCodes | SheCodes
Learn how to perform case-insensitive comparisons in JavaScript using toLowerCase(), toUpperCase(), and regular expressions with the i flag.
Find elsewhere
🌐
Javascripts
javascripts.com › perform-case-insensitive-includes-in-javascript
How to Perform Case-Insensitive Includes in JavaScript
June 23, 2023 - In the given JavaScript code, we are creating a new instance of RegExp using the keyword we want to match, and specifying the ‘i’ flag for case-insensitive matching. The test() method of the RegExp object then checks if our input string contains the keyword and returns a boolean value.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › compare-the-case-insensitive-strings-in-javascript
JavaScript - Compare the Case Insensitive Strings - GeeksforGeeks
July 11, 2025 - You can use a regular expression with the i flag (case-insensitive) to match strings. ... const comStr = (s1, s2) => new RegExp(`^${s1}$`, "i").test(s2); const s1 = "Hello"; const s2 = "hello"; console.log(comStr(s1, s2)); ... This method is ...
🌐
W3Resource
w3resource.com › javascript-exercises › javascript-string-exercise-38.php
JavaScript validation with regular expression: Create a case-insensitive search - w3resource
It uses the "search()" method with a regular expression constructed using 'RegExp' with the "i" flag to indicate case insensitivity. If a match is found, it returns 'Matched', otherwise 'Not Matched'.
🌐
Esdiscuss
esdiscuss.org › topic › case-insensitive-string-startswith-contains-endswith-replaceall-method
Case insensitive String startsWith, contains, endsWith, replaceAll method
And to make it case sensitive we should add a third flag parameter matchCase like... var startsWith = str.startsWith(searchString [, position [, matchCase] ] ); var contained = str.contains(searchString [, position [, matchCase] ] ); var endsWith = str.endsWith(searchString [, position [, ...
🌐
30 Seconds of Code
30secondsofcode.org › home › javascript › string › string contains substring
Check if a string contains a substring in JavaScript - 30 seconds of code
July 27, 2022 - If you need to search for a substring that is case-insensitive, you can use String.prototype.toLowerCase() to convert both strings to lowercase. Then you can compare them, using any of the previous methods. const str = 'Hello world'; const token ...
🌐
Dirask
dirask.com › posts › JavaScript-string-contains-case-insensitive-1Rv0M1
JavaScript - string contains case insensitive
JavaScript. In this example, we convert whole text string to lowercase, then we search for the word (also in lowercase) to find out if the word is present in the string (true) or not (false).
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › RegExp › ignoreCase
RegExp.prototype.ignoreCase - JavaScript | MDN
RegExp.prototype.ignoreCase has the value true if the i flag was used; otherwise, false. The i flag indicates that case should be ignored while attempting a match in a string. Case-insensitive matching is done by mapping both the expected character set and the matched string to the same casing.
🌐
GeeksforGeeks
geeksforgeeks.org › case-insensitive-search-in-javascript
Case insensitive search in JavaScript | GeeksforGeeks
September 27, 2021 - Case-insensitive: It means the text or typed input that is not sensitive to capitalization of letters, like "Geeks" and "GEEKS" must be treated as same in case-insensitive search.
🌐
SitePoint
sitepoint.com › javascript
Javascript Replace Making it Case Insensitive - JavaScript - SitePoint Forums | Web Development & Design Community
December 12, 2004 - How do I make a Javascript replace search case insensitive? My original string contains tags which are mostly lowercase. My function that produces the search substring uses the innerHTML property and as such it automaticaly converts all tags to uppercase. So to do the search and replace correctly ...
🌐
Linux Hint
linuxhint.com › check-if-string-contains-case-insensitive-text-javascript
How to Check if String Contains Text (Case Insensitive) in ...
Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use