Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
CrlUrlParserService
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
2 / 2
4
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 parseUrl
100.00% covered (success)
100.00%
11 / 11
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3declare(strict_types=1);
4
5/**
6 * SPDX-FileCopyrightText: 2026 LibreCode coop and contributors
7 * SPDX-License-Identifier: AGPL-3.0-or-later
8 */
9
10namespace OCA\Libresign\Service\Crl;
11
12use OCP\IURLGenerator;
13
14class CrlUrlParserService {
15    public function __construct(
16        private IURLGenerator $urlGenerator,
17    ) {
18    }
19
20    public function parseUrl(string $crlUrl): ?array {
21        $path = parse_url($crlUrl, PHP_URL_PATH);
22        if (!is_string($path)) {
23            return null;
24        }
25
26        $pattern = '#^/(?:index\.php/)?apps/libresign/crl/libresign_(?P<instanceId>[A-Za-z0-9]+)_(?P<generation>\d+)_(?P<engineType>[a-z])\.crl$#';
27        if (!preg_match($pattern, $path, $matches)) {
28            return null;
29        }
30
31        return [
32            'instanceId' => $matches['instanceId'],
33            'generation' => (int)$matches['generation'],
34            'engineType' => $matches['engineType'],
35        ];
36    }
37
38}