1 package com.atlassian.core.util.zip;
2
3 import com.google.common.annotations.VisibleForTesting;
4 import org.apache.commons.lang.StringUtils;
5
6
7
8
9
10
11 class FilePathUtils
12 {
13
14
15
16
17
18 @VisibleForTesting
19 static String stripSlashes(final String path)
20 {
21 String result = path;
22 result = result.replaceAll("\\\\", "/");
23 result = result.replaceAll("(/)+", "/");
24 result = result.replaceAll("(\\.){2,}+/", "");
25 result = result.replaceAll("(\\./)", "");
26 if (StringUtils.startsWith(result, "/"))
27 {
28 result = StringUtils.substring(result, 1);
29 }
30 if (StringUtils.endsWith(result, "/"))
31 {
32 result = StringUtils.substring(result, 0, result.length() - 1);
33 }
34 return result;
35 }
36 }