Exemplo n.º 1
0
        public async Task <ReadmeModel> DownloadReadme(string mdUrl)
        {
            var result = new ReadmeModel
            {
                Readme = await http.GetStringAsync(mdUrl)
            };

            var basePath   = UriUtilities.GetBasePath(mdUrl);
            var imageLinks = FindImageLinks(basePath, result.Readme);

            var imagesDict = imageLinks.ToDictionary(kv => kv.Key,
                                                     kv => http.GetByteArrayAsync(kv.Value));

            foreach (var kv in imagesDict)
            {
                try
                {
                    result.Images[kv.Key] = await kv.Value;
                }
                catch (Exception ex)
                {
                    Debugger.Warn($"Error on downloading '{kv.Key}' from '{imageLinks[kv.Key]}': {ex.GetBaseException()}");
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public string ResolveExternal(string url)
        {
            if (UriUtilities.IsAbsoluteUrl(url) || string.IsNullOrEmpty(Index.Source))
            {
                return(url);
            }

            var baseUrl = UriUtilities.GetBasePath(Index.Source);

            return(UriUtilities.UrlCombine(baseUrl, url));
        }