antv-l7/.cache/strip-prefix.js

19 lines
305 B
JavaScript
Raw Normal View History

2019-11-21 12:04:58 +08:00
/**
* Remove a prefix from a string. Return the input string if the given prefix
* isn't found.
*/
export default (str, prefix = ``) => {
if (!prefix) {
return str
}
prefix += `/`
if (str.substr(0, prefix.length) === prefix) {
return str.slice(prefix.length - 1)
}
return str
}