mirror of
https://github.com/webui-dev/webui.git
synced 2024-09-11 22:17:13 +03:00
Updating webui_get_url
This commit is contained in:
parent
97857b1cce
commit
a068a84320
@ -416,15 +416,15 @@ WEBUI_EXPORT void webui_set_position(size_t window, unsigned int x, unsigned int
|
||||
WEBUI_EXPORT void webui_set_profile(size_t window, const char* name, const char* path);
|
||||
|
||||
/**
|
||||
* @brief Get the server URL
|
||||
* @brief Get the full current URL
|
||||
*
|
||||
* @param window The window number
|
||||
*
|
||||
* @return Returns the server URL
|
||||
* @return Returns the full URL string
|
||||
*
|
||||
* @example char* URL = webui_get_url(myWindow);
|
||||
* @example const char* url = webui_get_url(myWindow);
|
||||
*/
|
||||
WEBUI_EXPORT char* webui_get_url(size_t window);
|
||||
WEBUI_EXPORT const char* webui_get_url(size_t window);
|
||||
|
||||
// -- JavaScript ----------------------
|
||||
|
||||
|
10
src/webui.c
10
src/webui.c
@ -43,6 +43,7 @@
|
||||
#define WEBUI_MIN_Y (0) // Minimal window Y
|
||||
#define WEBUI_MAX_X (3000) // Maximal window X (4K Monitor)
|
||||
#define WEBUI_MAX_Y (1800) // Maximal window Y (4K Monitor)
|
||||
#define WEBUI_HOSTNAME "localhost" // Host name to use `localhost` / `127.0.0.1`
|
||||
|
||||
// Mutex
|
||||
#ifdef _WIN32
|
||||
@ -1142,7 +1143,8 @@ void webui_set_profile(size_t window, const char* name, const char* path) {
|
||||
win->custom_profile = true;
|
||||
}
|
||||
|
||||
char* webui_get_url(size_t window) {
|
||||
const char* webui_get_url(size_t window) {
|
||||
|
||||
#ifdef WEBUI_LOG
|
||||
printf("[User] webui_get_url([%zu])...\n", window);
|
||||
#endif
|
||||
@ -1152,11 +1154,7 @@ char* webui_get_url(size_t window) {
|
||||
if(_webui_core.exit_now || _webui_core.wins[window] == NULL) return NULL;
|
||||
_webui_window_t* win = _webui_core.wins[window];
|
||||
|
||||
// Get current URL
|
||||
char* url = (char*) _webui_malloc(32);
|
||||
sprintf(url, "http://127.0.0.1:%zu", win->server_port);
|
||||
|
||||
return url;
|
||||
return (const char*)win->url;
|
||||
}
|
||||
|
||||
void webui_send_raw(size_t window, const char* function, const void* raw, size_t size) {
|
||||
|
Loading…
Reference in New Issue
Block a user