Here you can find the source of sanitize(String path)
Parameter | Description |
---|---|
path | a parameter |
public static String sanitize(String path)
//package com.java2s; //License from project: Apache License public class Main { /**/*from www . ja v a2 s .c om*/ * Sanitizes path by ensuring that path starts with a slash and doesn't have one at the end * @param path * @return */ public static String sanitize(String path) { return withLeadingSlash(withoutSlashAtEnd(path)); } private static String withLeadingSlash(String value) { return value.startsWith("/") ? value : "/" + value; } private static String withoutSlashAtEnd(String value) { return value.endsWith("/") ? value.substring(0, value.length() - 1) : value; } }