Read local files instead of performing self HTTP requests in JsonLD::documentLoader

This commit is contained in:
Hypolite Petovan 2023-01-28 22:13:15 -05:00
parent 6dfa492521
commit 1dc97e30e0

View File

@ -44,26 +44,26 @@ class JsonLD
{ {
switch ($url) { switch ($url) {
case 'https://w3id.org/security/v1': case 'https://w3id.org/security/v1':
$url = DI::baseUrl() . '/static/security-v1.jsonld'; $url = DI::basePath() . '/static/security-v1.jsonld';
break; break;
case 'https://w3id.org/identity/v1': case 'https://w3id.org/identity/v1':
$url = DI::baseUrl() . '/static/identity-v1.jsonld'; $url = DI::basePath() . '/static/identity-v1.jsonld';
break; break;
case 'https://www.w3.org/ns/activitystreams': case 'https://www.w3.org/ns/activitystreams':
$url = DI::baseUrl() . '/static/activitystreams.jsonld'; $url = DI::basePath() . '/static/activitystreams.jsonld';
break; break;
case 'https://funkwhale.audio/ns': case 'https://funkwhale.audio/ns':
$url = DI::baseUrl() . '/static/funkwhale.audio.jsonld'; $url = DI::basePath() . '/static/funkwhale.audio.jsonld';
break; break;
default: default:
switch (parse_url($url, PHP_URL_PATH)) { switch (parse_url($url, PHP_URL_PATH)) {
case '/schemas/litepub-0.1.jsonld'; case '/schemas/litepub-0.1.jsonld';
$url = DI::baseUrl() . '/static/litepub-0.1.jsonld'; $url = DI::basePath() . '/static/litepub-0.1.jsonld';
break; break;
case '/apschema/v1.2': case '/apschema/v1.2':
case '/apschema/v1.9': case '/apschema/v1.9':
case '/apschema/v1.10': case '/apschema/v1.10':
$url = DI::baseUrl() . '/static/apschema.jsonld'; $url = DI::basePath() . '/static/apschema.jsonld';
break; break;
default: default:
Logger::info('Got url', ['url' =>$url]); Logger::info('Got url', ['url' =>$url]);