Skip to content

Commit 21a1e73

Browse files
committed
Fix saucer v8 uri retrieving (part 2)
1 parent c14d1e1 commit 21a1e73

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/WebView/WebView.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ final class WebView implements
8181
* ```
8282
*/
8383
get {
84-
$result = $this->saucer->saucer_webview_url($this->id->ptr, \FFI::addr(
84+
$ptr = $this->saucer->saucer_webview_url($this->id->ptr, \FFI::addr(
8585
$error = $this->saucer->new('int'),
8686
));
8787

@@ -90,9 +90,21 @@ final class WebView implements
9090
}
9191

9292
try {
93-
return Request::castUrl(\FFI::string($result));
93+
$length = $this->saucer->new('size_t');
94+
$this->saucer->saucer_url_string($ptr, null, \FFI::addr($length));
95+
96+
if ($length->cdata === 0) {
97+
return new Uri();
98+
}
99+
100+
$url = $this->saucer->new("char[{$length->cdata}]");
101+
$this->saucer->saucer_url_string($ptr, \FFI::addr($url[0]), \FFI::addr($length));
102+
103+
$urlString = \FFI::string(\FFI::addr($url[0]), $length->cdata);
104+
105+
return Request::castUrl($urlString);
94106
} finally {
95-
\FFI::free($result);
107+
\FFI::free($ptr);
96108
}
97109
}
98110
/**

0 commit comments

Comments
 (0)