Esempio n. 1
0
        /// <summary>
        /// Builds a Facebook canvas return URL.
        /// </summary>
        /// <param name="pathAndQuery">The path and query.</param>
        /// <returns>
        /// The canvas url.
        /// </returns>
        public Uri BuildCanvasUrl(string pathAndQuery)
        {
            Contract.Requires(!String.IsNullOrEmpty(pathAndQuery));
            Contract.Ensures(Contract.Result <Uri>() != null);

            pathAndQuery = FacebookUtils.RemoveStartingSlash(pathAndQuery);

            var canvasUrl = IsSecureConnection ? SecureCanvasUrl : CanvasUrl;

            if (canvasUrl.PathAndQuery != "/" && pathAndQuery.StartsWith(canvasUrl.PathAndQuery))
            {
                pathAndQuery = pathAndQuery.Substring(canvasUrl.PathAndQuery.Length);
            }

            var url = string.Concat(canvasUrl, pathAndQuery);

            return(new Uri(FacebookUtils.RemoveTrailingSlash(url)));
        }