ReplaceToken
This commit is contained in:
parent
a5f8536211
commit
71e17741b5
|
|
@ -16,6 +16,9 @@ public partial class PlaywrightWebDriver
|
|||
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
{
|
||||
var webDriverService = _services.GetRequiredService<WebDriverService>();
|
||||
url = webDriverService.ReplaceToken(url);
|
||||
|
||||
var response = await page.GotoAsync(url, new PageGotoOptions
|
||||
{
|
||||
Timeout = 15 * 1000
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
using BotSharp.Plugin.WebDriver.LlmContexts;
|
||||
|
||||
namespace BotSharp.Plugin.WebDriver.Services;
|
||||
|
||||
public partial class WebDriverService
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace BotSharp.Plugin.WebDriver.Services;
|
||||
|
||||
public partial class WebDriverService
|
||||
{
|
||||
/// <summary>
|
||||
/// Replace token started @ with settings.
|
||||
/// </summary>
|
||||
/// <param name="text"></param>
|
||||
/// <returns></returns>
|
||||
public string ReplaceToken(string text)
|
||||
{
|
||||
var config = _services.GetRequiredService<IConfiguration>();
|
||||
var token = Regex.Match(text, "@[a-zA-Z0-9._]+");
|
||||
if (token.Success)
|
||||
{
|
||||
var key = token.Value.Replace("@", "").Replace(".", ":");
|
||||
var value = config.GetValue<string>(key);
|
||||
return text.Replace(token.Value, value);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue