<commit_before>package utils;

import java.net.URLConnection;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.util.HashMap;
import java.util.Map;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

import org.webdsl.logging.Logger;

import utils.File;

public class URLType {
    
	
	/*	
		tests: @ https://regex101.com/r/pH6cY5/1
		inspired by https://mathiasbynens.be/demo/url-regex and the pattern from @imme_emosol
		
		Accepts any protocol (required)
	*/
    public static Boolean isValid(String s){
      if(s != null && s.equals("") || s.matches("^(([a-zA-Z]+:\\/\\/)|mailto:)(-\\.)?(([^\\s\\/?\\.#\\-]+|([^\\s\\/?\\.#\\-]-[^\\s\\/?\\.#\\-]))\\.?)+(\\/[^\\s]*)?$")) {
        return true;
      }
      return false;
    }
    
	private static SSLSocketFactory sslSocketFactory = null;
	<commit_msg>Update pattern to handle URLs with multiple hypens (http://a-b-c.def.com)<commit_after>package utils;

import java.net.URLConnection;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.security.cert.X509Certificate;
import java.util.HashMap;
import java.util.Map;

import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;

import org.webdsl.logging.Logger;

import utils.File;

public class URLType {
    
	
	/*	
		tests: @ https://regex101.com/r/pH6cY5/1
		inspired by https://mathiasbynens.be/demo/url-regex and the pattern from @imme_emosol
		
		Accepts any protocol (required)
	*/
    public static Boolean isValid(String s){
      if(s != null && s.equals("") || s.matches("^(([a-zA-Z]+:\\/\\/)|mailto:)(-\\.)?([^\\s\\/?\\.#\\-](-*[^\\s\\/?\\.#\\-])*\\.?)+(\\/[^\\s]*)?$")) {
        return true;
      }
      return false;
    }
    
	private static SSLSocketFactory sslSocketFactory = null;
	
{'fraction_non_alphanumeric': 0.18113706478624944, 'fraction_numerical': 0.010577346848832084, 'mean_word_length': 3.486166007905138, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6326495', 'n_tokens_mistral': 842, 'n_tokens_neox': 793, 'n_words': 142}