summaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/helpers/path.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/helpers/path.js')
-rw-r--r--server/sonar-web/src/main/js/helpers/path.js13
1 files changed, 13 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/helpers/path.js b/server/sonar-web/src/main/js/helpers/path.js
index c0a16a4ea9e..a03c1421bf1 100644
--- a/server/sonar-web/src/main/js/helpers/path.js
+++ b/server/sonar-web/src/main/js/helpers/path.js
@@ -94,3 +94,16 @@ export function fileFromPath (path) {
return null;
}
}
+
+
+export function splitPath (path) {
+ if (typeof path === 'string') {
+ const tokens = path.split('/');
+ return {
+ head: _.initial(tokens).join('/'),
+ tail: _.last(tokens)
+ };
+ } else {
+ return null;
+ }
+}