UNPKG

305 BJavaScriptView Raw
1/**
2 * Remove a prefix from a string. Return the input string if the given prefix
3 * isn't found.
4 */
5
6export default (str, prefix = ``) => {
7 if (!prefix) {
8 return str
9 }
10
11 prefix += `/`
12
13 if (str.substr(0, prefix.length) === prefix) {
14 return str.slice(prefix.length - 1)
15 }
16
17 return str
18}