UNPKG

365 BJavaScriptView Raw
1module.exports = function getFileKey(p) {
2 if (!p) return null;
3
4 if (/^\//.test(p)) {
5 return getFileKey(p.substr(1));
6 }
7
8 if (
9 !/^(layout|content|frame|pages|templates|sections|snippets|config|locales|assets)/.test(
10 p
11 )
12 ) {
13 return getFileKey(
14 p
15 .split("/")
16 .slice(1)
17 .join("/")
18 );
19 }
20
21 return p;
22};