mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-06 17:49:40 +00:00
ensured data sources can be renamed and made it secure
This commit is contained in:
1 parent
202e37410b
commit
92e986d9b9
13 files changed
+137
-66
No files matched your search
@@ -2,20 +2,11 @@ namespace AIStudio.Tools.Services;
|
||||
|
||||
internal static class DataSourceEmbeddingNames
|
||||
{
|
||||
public static string GetCollectionName(string dataSourceName, string dataSourceId)
|
||||
public static string GetCollectionName(string dataSourceId)
|
||||
{
|
||||
var safeId = dataSourceId
|
||||
.ToLowerInvariant()
|
||||
.Replace("-", string.Empty, StringComparison.Ordinal);
|
||||
if (!Guid.TryParse(dataSourceId, out var parsedDataSourceId))
|
||||
throw new ArgumentException("Data source ID must be a valid GUID.", nameof(dataSourceId));
|
||||
|
||||
var safeName = new string(dataSourceName
|
||||
.ToLowerInvariant()
|
||||
.Where(c => c is >= 'a' and <= 'z' or >= '0' and <= '9')
|
||||
.Take(32)
|
||||
.ToArray());
|
||||
|
||||
safeName = string.IsNullOrWhiteSpace(safeName) ? "datasource" : safeName;
|
||||
|
||||
return $"rag_{safeName}_{safeId}";
|
||||
return $"rag_{parsedDataSourceId:N}";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user