diff options
| author | winter | 2024-12-06 20:43:26 +0000 |
|---|---|---|
| committer | winter | 2024-12-06 20:43:26 +0000 |
| commit | e1ad307b531c27ec6bfaf8b4d018991b0d4a78f3 (patch) | |
| tree | 4ef08af2b4051d433bb929d5162474ac6777cab1 /misc/path_to_uri.php | |
initial commit
hardcoded functionality mostly!
Diffstat (limited to 'misc/path_to_uri.php')
| -rw-r--r-- | misc/path_to_uri.php | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/misc/path_to_uri.php b/misc/path_to_uri.php new file mode 100644 index 0000000..756640e --- /dev/null +++ b/misc/path_to_uri.php @@ -0,0 +1,16 @@ +<?php + +use WpfTest\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; +}
\ No newline at end of file |
