]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - application/api/ApiUtils.php
Run Unit Tests against PHP 7.4
[github/shaarli/Shaarli.git] / application / api / ApiUtils.php
index fc5ecaf1e75931d3a2006dae957be7129bb7df1e..5ac07c4d2f0e7331969f714325d00ce6a68a1edb 100644 (file)
@@ -1,8 +1,8 @@
 <?php
 namespace Shaarli\Api;
 
-use Shaarli\Base64Url;
 use Shaarli\Api\Exceptions\ApiAuthorizationException;
+use Shaarli\Http\Base64Url;
 
 /**
  * REST API utilities
@@ -12,9 +12,11 @@ class ApiUtils
     /**
      * Validates a JWT token authenticity.
      *
-     * @param string $token JWT token extracted from the headers.
+     * @param string $token  JWT token extracted from the headers.
      * @param string $secret API secret set in the settings.
      *
+     * @return bool true on success
+     *
      * @throws ApiAuthorizationException the token is not valid.
      */
     public static function validateJwtToken($token, $secret)
@@ -45,12 +47,14 @@ class ApiUtils
         ) {
             throw new ApiAuthorizationException('Invalid JWT issued time');
         }
+
+        return true;
     }
 
     /**
      * Format a Link for the REST API.
      *
-     * @param array $link Link data read from the datastore.
+     * @param array  $link     Link data read from the datastore.
      * @param string $indexUrl Shaarli's index URL (used for relative URL).
      *
      * @return array Link data formatted for the REST API.
@@ -59,7 +63,7 @@ class ApiUtils
     {
         $out['id'] = $link['id'];
         // Not an internal link
-        if ($link['url'][0] != '?') {
+        if (! is_note($link['url'])) {
             $out['url'] = $link['url'];
         } else {
             $out['url'] = $indexUrl . $link['url'];