Last active
May 19, 2021 15:57
-
-
Save nkpremices/f5d5d35c95a2792adc70104f627d55a2 to your computer and use it in GitHub Desktop.
switch statement with regexp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getAdminTitle = (locationPathname: string) => { | |
switch (locationPathname) { | |
case '/admin': | |
return 'admin'; | |
case ( | |
locationPathname.match( | |
'/admin/[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}/offers', | |
) || {} | |
).input: | |
return 'offers' | |
default: | |
return 'admin'; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment