Skip to content

Commit

Permalink
refactor: GQL responses need to include the path prefix, too
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed Sep 13, 2024
1 parent 9760b06 commit 9027b92
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/gql/resolvers/RetourResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
use craft\base\Element;
use craft\errors\SiteNotFoundException;
use craft\gql\base\Resolver;
use craft\helpers\UrlHelper;
use GraphQL\Type\Definition\ResolveInfo;
use nystudio107\retour\helpers\UrlHelper;
use nystudio107\retour\Retour;

/**
Expand Down Expand Up @@ -75,6 +75,17 @@ public static function resolve($source, array $arguments, $context, ResolveInfo
Retour::$plugin->statistics->incrementStatistics($uri, false, $siteId);
}
}
$dest = $redirect['redirectDestUrl'];
// If this isn't an absolute URL, make it one based on the appropriate site
if (!UrlHelper::isAbsoluteUrl($dest)) {
try {
$dest = UrlHelper::siteUrl($dest, null, null, $siteId);
$dest = parse_url($dest, PHP_URL_PATH);
} catch (Throwable $e) {

Check failure on line 84 in src/gql/resolvers/RetourResolver.php

View workflow job for this annotation

GitHub Actions / PHPStan

Caught class nystudio107\retour\gql\resolvers\Throwable not found.
// That's ok
}
}
$redirect['redirectDestUrl'] = $dest;

return $redirect;
}
Expand Down

0 comments on commit 9027b92

Please sign in to comment.