mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
938 B
23 lines
938 B
using System;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace Volo.Docs.Pages.Documents.Project
|
|
{
|
|
public static class HtmlNormalizer
|
|
{
|
|
public static string ReplaceImageSources(string content, string documentRawRootUrl, string localDirectory)
|
|
{
|
|
content = Regex.Replace(content, @"(<img\s+[^>]*)src=""([^""]*)""([^>]*>)", delegate (Match match)
|
|
{
|
|
var newImageSource = documentRawRootUrl.EnsureEndsWith('/') +
|
|
(localDirectory.IsNullOrEmpty() ? "" : localDirectory.TrimStart('/').EnsureEndsWith('/')) +
|
|
match.Groups[2].Value.TrimStart('/');
|
|
return match.Groups[1] + " src=\"" + newImageSource + "\" " + match.Groups[3];
|
|
|
|
}, RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.Multiline);
|
|
|
|
|
|
return content;
|
|
}
|
|
}
|
|
}
|