All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kukababy.utils.UrlUtil Maven / Gradle / Ivy

The newest version!
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kukababy.utils;

import java.util.regex.Pattern;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @describe 描述
 * @author [email protected]
 * @date 2014-3-26
 */
public class UrlUtil {
	private static final Logger log = LoggerFactory.getLogger(UrlUtil.class);
	
	public static void main(String args[]) {
		
		Pattern exclusions = exclusionsReg("/,/login,/login.html,*.js,*.gif,*.jpg,*.png,*.css,*.ico,*.bmp,/images/*");
		
		System.out.println(exclusions.matcher("/images/a.html").matches());
	}
	
	public static Pattern exclusionsReg(String _exclusions) {

		String dars[] = _exclusions.split(",");
		StringBuilder sb = new StringBuilder();
		for (String key : dars) {
			if (sb.length() > 0) {
				sb.append("||");
			}
			key = key.replaceAll("\\.", "\\\\.");
			key = key.replaceAll("\\*", ".*");
			sb.append("(").append(key).append(")");
		}
		log.info(sb.toString());
		return Pattern.compile(sb.toString());
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy