JSFiddle - React, Tailwind, and code Playground
by kanelbula
CoffeeScript
url1 = '/course/chapter/learning-know-yourself-your-actions/'
url2 = '/course/chapter/learning-know-yourself-your-actions/end/'
url3 = '/course/showcase/'
regex_chapter_end = /// ^/course/chapter # beginning of url
(?:.*) # chapter id
/end/$ # end of url
///
regex_chapter = /^\/course\/chapter\/(?:(.*))\/$/
regex_home = /^\/course\/showcase\/$/
# Test if it is a chapter page url
result = regex_chapter.exec(url1)
if result?
console.log "chapter page. id: #{result[1]}"
# Test if it is a chapter end page
result = regex_chapter_end.exec(url2)
if result?
console.log "chapter page end. id: #{result[1]}"
console.log regex_home.test(url3)