Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get URL #682

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open

Get URL #682

wants to merge 20 commits into from

Conversation

dandeto
Copy link
Collaborator

@dandeto dandeto commented Feb 23, 2022

Another simple pull request for another simple cross-platform API. Not implemented for MacOs because I don't have one. Stub only for EdgeHtml since we are discussing removing it.
std::string get_url() returns the current URL.

webview.h Outdated Show resolved Hide resolved
@vitalyster
Copy link
Contributor

vitalyster commented Feb 24, 2022

cross-platform
Not implemented for MacOs

Are you sure this should be allowed?

@justjosias
Copy link
Member

We're not going to merge anything that doesn't support all platforms. However, this is a good start for Linux and Windows.

@SteffenL SteffenL changed the title Get url Get URL Feb 15, 2024
@SteffenL
Copy link
Collaborator

Sorry it took me so long to take a proper look at this. I've added a few safety checks, macOS implementation and C API.

As we didn't have any existing functions in the C API that return strings of unknown length, I wasn't quite sure what would be the best way to do so.

I ended up going with an approach where the library by default dynamically allocates the memory needed and then returning it to the caller, with a way for the caller to choose how to allocate the string. I initially thought about webview_get_url taking an output buffer and max size, but I thought it would increase the complexity both for the caller and the library when having to deal with input validation errors and buffers that aren't large enough.

I remember testing this PR a while back and found that we can't always expect webview_get_url() to return the same URL given to webview_navigate() immediately after navigation has begun. For example, it might be OK with WebKitGTK (Linux), but with WebView2 (Windows) we might get about:blank, and the expected URL after pumping the message loop for a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants