core/src/main/java/com/digitalpebble/stormcrawler/filtering/basic/BasicURLNormalizer.java
private String escapePath(String path) {
        StringBuilder sb = new StringBuilder(path.length());

        // Traverse over all bytes in this URL
        for (byte b : path.getBytes(utf8)) {
            // Is this a control character?
            if (b < 33 || b == 91 || b == 92 || b == 93 || b == 124) {
                // Start escape sequence
                sb.append('%');

                // Get this byte's hexadecimal representation
                String hex = Integer.toHexString(b & 0xFF).toUpperCase(
                        Locale.ROOT);

                // Do we need to prepend a zero?
                if (hex.length() % 2 != 0) {
                    sb.append('0');
                    sb.append(hex);
                } else {
                    // No, append this hexadecimal representation
                    sb.append(hex);
                }
            } else {
                // No, just append this character as-is
                sb.append((char) b);
            }
        }

        return sb.toString();
    }
private String escapePath(String path) {
        StringBuilder sb = new StringBuilder(path.length());

        // Traverse over all bytes in this URL
        for (byte b : path.getBytes(utf8)) {
            // Is this a control character?
            if (b < 33 || b == 91 || b == 92 || b == 93 || b == 124) {
                // Start escape sequence
                sb.append('%');

                // Get this byte's hexadecimal representation
                String hex = Integer.toHexString(b & 0xFF).toUpperCase(
                        Locale.ROOT);

                // Do we need to prepend a zero?
                if (hex.length() % 2 != 0) {
                    sb.append('0');
                    sb.append(hex);
                } else {
                    // No, append this hexadecimal representation
                    sb.append(hex);
                }
            } else {
                // No, just append this character as-is
                sb.append((char) b);
            }
        }

        return sb.toString();
    }
private String escapePath ( String path ) { StringBuilder sb = new StringBuilder ( path . length ( ) ) ; // Traverse over all bytes in this URL for ( byte b : path . getBytes ( utf8 ) ) { // Is this a control character? if ( b < 33 || b == 91 || b == 92 || b == 93 || b == 124 ) { // Start escape sequence sb . append ( ' ' ) ; // Get this byte's hexadecimal representation String hex = Integer . toHexString ( b & 0xFF ) . toUpperCase ( Locale . ROOT ) ; // Do we need to prepend a zero? if ( hex . length ( ) % 2 != 0 ) { sb . append ( ' ' ) ; sb . append ( hex ) ; } else { // No, append this hexadecimal representation sb . append ( hex ) ; } } else { // No, just append this character as-is sb . append ( ( char ) b ) ; } } return sb . toString ( ) ; }
Convert path segment of URL from Unicode to UTF-8 and escape all
characters which should be escaped according to <a
href="https://tools.ietf.org/html/rfc3986#section-2.2">RFC3986</a>..
Convert path segment of URL from Unicode to UTF - 8 and escape all characters which should be escaped according to <a href = https : // tools . ietf . org / html / rfc3986#section - 2 . 2 > RFC3986< / a > ..