Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fun localFileFromRequestUri(basePath: File, uri: URI): File {
- val basePathElements = basePath.absolutePath.split(File.separator).filter { it.isNotEmpty() }.toMutableSet()
- val clientPathElements = uri.path.substring(1).split(File.separatorChar)
- val filteredPathElements = clientPathElements.mapNotNull {
- if (!basePathElements.remove(it)) {
- it
- } else {
- null
- }
- }.joinToString(separator = File.separator) { it }
- return File(basePath, filteredPathElements)
- }
Add Comment
Please, Sign In to add comment