aboutsummaryrefslogtreecommitdiffhomepage
path: root/misc/path_to_uri.php
blob: 1e2c2fb930d1bfa70eae9e03b9d5d237a323ed60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php

use Digitigrade\GlobalConfig;


/**
 * Converts an absolute path into an absolute URI based on the instance's base path
 * @param string $path absolute path (i.e. must start with a `/`)
 * @return string absolute URI
 */
function path_to_uri(string $path): string {
    if (!str_starts_with($path, '/')) {
        throw new InvalidArgumentException('path must be absolute (start with a `/`');
    }
    return GlobalConfig::getInstance()->getBasePath() . $path;
}