Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/treetrek.git

Simplifies router URL

AuthorDave Jarvis <email>
Date2026-02-12 13:00:16 GMT-0800
Commit89f4b3f3c11dcc4605acbb2babeb729f3fc75b70
Parentf9319e4
Router.php
$action = $_GET['action'] ?? 'file';
$hash = $this->sanitize( $_GET['hash'] ?? '' );
+ $subPath = '';
+
+ $uri = parse_url( $_SERVER['REQUEST_URI'], PHP_URL_PATH );
+ $scriptName = $_SERVER['SCRIPT_NAME'];
+
+ if ( strpos( $uri, $scriptName ) === 0 ) {
+ $uri = substr( $uri, strlen( $scriptName ) );
+ }
+
+ if( preg_match( '#^/([^/]+)\.git(?:/(.*))?$#', $uri, $matches ) ) {
+ $reqRepo = urldecode( $matches[1] );
+ $subPath = isset( $matches[2] ) ? ltrim( $matches[2], '/' ) : '';
+ $action = 'clone';
+ }
$currRepo = null;
- $subPath = '';
$decoded = urldecode( $reqRepo );
Delta14 lines added, 1 line removed, 13-line increase