Skip to content
Snippets Groups Projects
Commit f360f157 authored by Hanna Führ's avatar Hanna Führ Committed by Petar Hristov
Browse files

Fix: Encoding the path

parent 563c1787
No related branches found
No related tags found
1 merge request!66Fix: Encoding the path
using Coscine.Configuration; using Coscine.Configuration;
using Coscine.Metadata.Util; using Coscine.Metadata.Util;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using NUnit.Framework; using NUnit.Framework;
using NUnit.Framework.Internal; using NUnit.Framework.Internal;
using System; using System;
using System.Linq; using System.Linq;
using System.Text;
using VDS.RDF; using VDS.RDF;
using VDS.RDF.Parsing; using VDS.RDF.Parsing;
......
...@@ -7,6 +7,7 @@ using VDS.RDF.Parsing; ...@@ -7,6 +7,7 @@ using VDS.RDF.Parsing;
using VDS.RDF.Query; using VDS.RDF.Query;
using VDS.RDF; using VDS.RDF;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web;
namespace Coscine.Metadata namespace Coscine.Metadata
{ {
...@@ -48,7 +49,7 @@ namespace Coscine.Metadata ...@@ -48,7 +49,7 @@ namespace Coscine.Metadata
public List<string> GetDataIds(string? resourceId = null, string? path = null, bool extracted = false, bool includeInvalidated = false) public List<string> GetDataIds(string? resourceId = null, string? path = null, bool extracted = false, bool includeInvalidated = false)
{ {
var resourceGraphUri = $"https://purl.org/coscine/resources/{resourceId}"; var resourceGraphUri = $"https://purl.org/coscine/resources/{resourceId}";
var pathGraphUri = path != null ? $"{resourceGraphUri}/{(path.StartsWith("/") ? path[1..] : path)}/" : ""; var pathGraphUri = path != null ? $"{resourceGraphUri}/{HttpUtility.UrlPathEncode(path.StartsWith("/") ? path[1..] : path)}/" : "";
var query = $@"{{ var query = $@"{{
" + ((resourceId != null) ? $"@resource <{Uris.DcatCatalog}>* ?g ." : "") + $@" " + ((resourceId != null) ? $"@resource <{Uris.DcatCatalog}>* ?g ." : "") + $@"
...@@ -129,7 +130,7 @@ namespace Coscine.Metadata ...@@ -129,7 +130,7 @@ namespace Coscine.Metadata
public List<string> GetMetadataIds(string? resourceId = null, string? path = null, bool extracted = false) public List<string> GetMetadataIds(string? resourceId = null, string? path = null, bool extracted = false)
{ {
var resourceGraphUri = $"https://purl.org/coscine/resources/{resourceId}"; var resourceGraphUri = $"https://purl.org/coscine/resources/{resourceId}";
var pathGraphUri = path != null ? $"{resourceGraphUri}/{(path.StartsWith("/") ? path[1..] : path)}/" : ""; var pathGraphUri = path != null ? $"{resourceGraphUri}/{HttpUtility.UrlPathEncode(path.StartsWith("/") ? path[1..] : path)}/" : "";
var query = $@"{{ var query = $@"{{
" + ((resourceId != null) ? $"@resource <{Uris.DcatCatalog}>* ?g ." : "") + $@" " + ((resourceId != null) ? $"@resource <{Uris.DcatCatalog}>* ?g ." : "") + $@"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment