Package 

Class UrlBeaconUrlCompressor


  • 
    public class UrlBeaconUrlCompressor
    
                        

    Provides encoding / decoding functions for the URL beacon https://github.com/google/uribeacon

    • Method Summary

      Modifier and Type Method Description
      static Array<byte> compress(String urlString) Converts the given URL string into a byte array "compressed" version of the URL.The regex needs to determine what the URL starts with and what the hostname endswith.
      static String uncompress(Array<byte> compressedURL)
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • compress

         static Array<byte> compress(String urlString)

        Converts the given URL string into a byte array "compressed" version of the URL.The regex needs to determine what the URL starts with and what the hostname endswith. The URL must start with one of the following:http://www.https://www.http://https://The hostname may end with one of the following TLDs:.com.org.edu.net.info.biz.govIf the path component of the URL is non-empty, then the "slash" version ofthe matching TLD can be used. Otherwise, the "non-slash" version of the TLD is used.If the hostname doesn't end with a TLD, that's fine; it just isn't compressedinto a single byte.Therefore, the following regex should tell me what I need to know about the URL:^(http|https):\/\/(www.)?((?:[0-9a-z_-]+\.??)+)(\.[0-9a-z_-]+\/?)(.*)$Groups:1: http or https2: www. or empty3: hostname including optional leading www. but excluding trailing dot up to but not including TLD4: TLD with leading dot and optional trailing slash5: path without leading slash or empty