Skip to content

Commit

Permalink
custom request path parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
cdosoftei committed Jun 23, 2024
1 parent 5b24354 commit 87a3b46
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
13 changes: 9 additions & 4 deletions src/Browser/Main/WebView.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,20 @@ public function onRequest(WebViewRequest $request): void
{
assert($this->app instanceof App);

$uri = $request->getUri();
$parsed = parse_url($uri);

$body = str_replace(
[
'{{ scheme }}',
'{{ uri }}',
'{{ scheme }}',
'{{ host }}',
'{{ path }}',
], [
$request->getScheme(),
$request->getUri(),
$request->getPath(),
$uri,
$parsed['scheme'] ?? '',
$parsed['host'] ?? '',
$parsed['path'] ?? '',
],
$this->app->customHtml
);
Expand Down
3 changes: 2 additions & 1 deletion static/html/browser_custom.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
<h1>This page is served over a custom URI scheme!</h1>

<ul>
<li><i>Scheme</i>: <b>{{ scheme }}</b></li>
<li><i>URI</i>: <b>{{ uri }}</b></li>
<li><i>Scheme</i>: <b>{{ scheme }}</b></li>
<li><i>Host</i>: <b>{{ host }}</b></li>
<li><i>Path</i>: <b>{{ path }}</b></li>
</ul>
</body>
Expand Down
2 changes: 1 addition & 1 deletion static/html/browser_start.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h1>Welcome to the Ardillo Browser!</h1>

<ul>
<li><a href="https://ardillo.dev">ardillo.dev</a></li>
<li><a href="custom:///path/to/resource">custom:///path/to/resource</a> (showcases custom URI scheme handling)</li>
<li><a href="custom://host/path/to/resource">custom://host/path/to/resource</a> (showcases custom URI scheme handling)</li>
</ul>
</body>
</html>

0 comments on commit 87a3b46

Please sign in to comment.