mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
bring back hostname getter/setter functions
This was a regression while testing things.
This commit is contained in:
@@ -355,34 +355,33 @@ pub const HTMLAnchorElement = struct {
|
|||||||
return parser.anchorSetHref(self, u.getHref());
|
return parser.anchorSetHref(self, u.getHref());
|
||||||
}
|
}
|
||||||
|
|
||||||
//pub fn get_hostname(self: *parser.Anchor, page: *Page) ![]const u8 {
|
pub fn get_hostname(self: *parser.Anchor, page: *Page) []const u8 {
|
||||||
// const maybe_href_str = try getAnchorHref(self);
|
const u = getURL(self, page) catch return "";
|
||||||
// const href_str = maybe_href_str orelse return "";
|
return u.getHostname();
|
||||||
//
|
}
|
||||||
// const u = try NativeURL.parse(href_str, null);
|
|
||||||
// defer u.deinit();
|
|
||||||
//
|
|
||||||
// return page.arena.dupe(u8, u.getHostname());
|
|
||||||
//}
|
|
||||||
|
|
||||||
//pub fn set_hostname(self: *parser.Anchor, v: []const u8) !void {
|
pub fn set_hostname(self: *parser.Anchor, hostname: []const u8, page: *Page) !void {
|
||||||
// const maybe_href_str = try getAnchorHref(self);
|
const u = blk: {
|
||||||
//
|
if (page.getObjectData(self)) |internal_url| {
|
||||||
// if (maybe_href_str) |href_str| {
|
break :blk NativeURL.fromInternal(internal_url);
|
||||||
// const u = try NativeURL.parse(href_str, null);
|
}
|
||||||
// defer u.deinit();
|
|
||||||
//
|
const maybe_anchor_href = try getHref(self);
|
||||||
// try u.setHostname(v);
|
if (maybe_anchor_href) |anchor_href| {
|
||||||
//
|
const new_u = try NativeURL.parse(anchor_href, null);
|
||||||
// return parser.anchorSetHref(self, u.getHref());
|
try page.putObjectData(self, new_u.internal.?);
|
||||||
// }
|
break :blk new_u;
|
||||||
//
|
}
|
||||||
// // No href string there; use the given value as href.
|
|
||||||
// const u = try NativeURL.parse(v, null);
|
// Last resort; try to create URL object out of hostname.
|
||||||
// defer u.deinit();
|
const new_u = try NativeURL.parse(hostname, null);
|
||||||
//
|
// We can just return here since hostname is updated.
|
||||||
// return parser.anchorSetHref(self, u.getHref());
|
return page.putObjectData(self, new_u.internal.?);
|
||||||
//}
|
};
|
||||||
|
|
||||||
|
try u.setHostname(hostname);
|
||||||
|
return parser.anchorSetHref(self, u.getHref());
|
||||||
|
}
|
||||||
|
|
||||||
// TODO return a disposable string
|
// TODO return a disposable string
|
||||||
pub fn get_port(self: *parser.Anchor, page: *Page) ![]const u8 {
|
pub fn get_port(self: *parser.Anchor, page: *Page) ![]const u8 {
|
||||||
|
|||||||
Reference in New Issue
Block a user