123456789101112131415 |
- const prefixList = ['/app-api', '/admin-api']
- export const getSuffixAfterPrefix = (str) => {
- const matchingPrefix = prefixList.find(prefix => str.startsWith(prefix))
- if (matchingPrefix) {
- const matchUrl = str.slice(matchingPrefix.length)
- const hasQuery = matchUrl.indexOf('?') !== -1
- if (hasQuery) {
- const arr = matchUrl.split('?')
- return arr[0]
- }
- else return matchUrl
- }
- return undefined
- }
|