Reputation: 88
I am trying to implement a condition in my code :
let isShow : boolean;
const myString = 'gclid';
isShow = this.router.url.startsWith('?'+ myString +'=');
Now, the condition is that if in URL, it contains 'gclid' but its UpperCase like "GCLID" or it contains 'gclid' but any of the letter in URL substring is UpperCase like 'gClid', then it will return 'false'.
But according to requirement, it should return true if the url contains 'gclid' with ignoring Case.
Please suggest, if its possible, I have tried some workarounds, but till now not getting what's expected. Your help will be highly appreciable.
Thanks !
Upvotes: 1
Views: 1106
Reputation: 15423
Convert the string to lower case and then you can check if it is present in the url:
let show = this.router.url.toLocaleLowerCase().contains('gclid');
Upvotes: 3