package com.afi.autoquote.util
{
    public class URLUtil
    {
        // Turn a template object into a normal param string for HTTP
        public static function joinParams(params:Object):String {
            var joined:String = "";
            
            if(params != null) {
                joined = "?";
                
                var prop:String;
                var value:Object;
                for (prop in params) {
                    value = params[prop];
                    if(value != null) {
                        joined += prop + "=" + params[prop].toString() + "&";
                    }
                }
                
                // remove final &
                joined = joined.slice(0, joined.length - 1);
            }
            
            return joined;
        }
    }
}