Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Translumo.Infrastructure/Constants/RegexStorage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Text.RegularExpressions;
using System.Text.RegularExpressions;

namespace Translumo.Infrastructure.Constants
{
Expand Down Expand Up @@ -28,7 +28,7 @@ static RegexStorage()
EndDotRegex = new Regex(@"\.{3,}$", RegexOptions.Compiled);
GoogleTranslateResultRegex = new Regex("(?<=(<div(.*)class=\"result-container\"(.*)>))[\\s\\S]*?(?=(<\\/div>))", RegexOptions.Compiled | RegexOptions.IgnoreCase);
GuidGenerationRegex = new Regex("[xy]", RegexOptions.Compiled);
YandexSidRegex = new Regex(@"(?<=(SID\:\s*')).*(?=('))", RegexOptions.Compiled);
YandexSidRegex = new Regex(@"(?<=(sid\:\s*')).*(?=('))", RegexOptions.Compiled | RegexOptions.IgnoreCase);
DeeplSentenceRegex = new Regex(@"(\S.+?([.!?♪。]|$))([\r\n]+|(?=\s+|$))", RegexOptions.Compiled | RegexOptions.Multiline);
}
}
Expand Down
10 changes: 2 additions & 8 deletions src/Translumo.Translation/Yandex/YandexReaderProxy.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using System.Net.Http;
using System.Text.Json;
Expand Down Expand Up @@ -61,16 +61,10 @@ public string ExtractSid(string body)
return string.Empty;
}

const char SID_SEPARATOR = '.';

var match = RegexStorage.YandexSidRegex.Match(body);
if (match.Success)
{
var splittedReversed = match.Value
.Split(SID_SEPARATOR)
.Select(str => new string(str.Reverse().ToArray()));

return string.Join(SID_SEPARATOR, splittedReversed);
return match.Value;
}

return string.Empty;
Expand Down