/**
 * Copyright 2008-2009. Chongqing Communications Industry Services Co.,Ltd Information Technology Branch. All rights reserved.
 * <a>http://www.crunii.com</a>
 */
package com.crunii.micro.common.utils;

import com.google.common.base.Splitter;
import org.springframework.util.StringUtils;

import java.util.stream.Collectors;

/**
 * @author 田平 create 2021/10/8 16:06
 */
public class StripUrlUtil {

	public static String strip(String url, int parts) {
		if (StringUtils.hasText(url)) {
			String newPath = "/" + Splitter.on("/").omitEmptyStrings().trimResults().splitToList(url).stream()
					.skip(parts)
					.collect(Collectors.joining("/"));
			return newPath;
		} else {
			return null;
		}
	}

	public static void main(String[] args) {
		System.out.println(strip("/ab/dc/d", 1));
	}
}
