http://localhost:52717/ticketwizard/eventfeed/0/5868?keywordsearchstring=eventkeyword check if url containes "eventfeed" in javascript

One way to check if a given url contains the string "eventfeed" is by using the JavaScript includes() method. Below is a code snippet that demonstrates how to accomplish this:

index.tsx
const url = 'http://localhost:52717/ticketwizard/eventfeed/0/5868?keywordsearchstring=eventkeyword';
if (url.includes('eventfeed')) {
  console.log('The url contains "eventfeed"');
} else {
  console.log('The url does not contain "eventfeed"');
}
247 chars
7 lines

The includes() method returns a boolean value indicating whether or not the string "eventfeed" is found within the specified url. If the string is found, the code above will log "The url contains 'eventfeed'". If the string is not found, it will log "The url does not contain 'eventfeed'".

gistlibby LogSnag