Skip to content

Commit 56a1b4e

Browse files
author
Radek Hubner
committed
[bugfix] Fix bug #129, when foldername contains "content".
1 parent 52d9908 commit 56a1b4e

File tree

1 file changed

+2
-6
lines changed
  • csv-validator-core/src/main/scala/uk/gov/nationalarchives/csv/validator

1 file changed

+2
-6
lines changed

csv-validator-core/src/main/scala/uk/gov/nationalarchives/csv/validator/Util.scala

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,12 +218,8 @@ object Util {
218218
}
219219

220220
private def contentDir(filepath: String, topLevelFolder: String): String = {
221-
val list = (substitutePath(filepath) split topLevelFolder).toIterator.toList
222-
val pathList = if (list.length > 1) list.dropRight(1) else list
223-
val dir = pathList.tail.foldLeft(pathList.head){ case (acc, elem) =>
224-
acc + topLevelFolder + elem
225-
}
226-
FileSystem.file2PlatformIndependent(dir + topLevelFolder)
221+
val substPath = substitutePath(filepath).split("/").toSeq.reverse.dropWhile(!_.equals(topLevelFolder)).reverse.mkString("/")
222+
FileSystem.file2PlatformIndependent(substPath)
227223
}
228224

229225
def jointPath: String = {

0 commit comments

Comments
 (0)