I hadn’t restarted my computer since November so I had whatever version of MacOS was current then (I think it was 15.2 or 15.3). However yesterday I upgraded to 15.5 and suddenly this snippet no longer works:
on hostname for |url| as {record, text}
tell the |url| as {URL, record} to ¬
return the host's DNS form
end hostname
It returns this error message:
“Can’t get host of {«class ktxt»:"macscripter.net/new"}.” number -1728 from host of {«class ktxt»:“macscripter.net/new”}
I think this is just an input data issue. Internet address requires a complete TCP/IP protocol address not just a FQDN.
--Running under AppleScript 2.8, MacOS 15.5
set |url| to "http://www.apple.com"
hostname for |url| as {record, text}
-->"www.apple.com"
set |url| to "macscripter.net/new"
hostname for |url| as {record, text}
-->Can’t get host of {«class ktxt»:"macscripter.net/new"}.
set |url| to "http://www.macscripter.net/new"
hostname for |url| as {record, text}
-->"www.macscripter.net"
on hostname for |url| as {record, text}
tell the |url| as {URL, record} to ¬
return the host's DNS form
end hostname
The as {record, text} nonsense doesn’t seem to be necessary either:
--Running under AppleScript 2.8, MacOS 15.5
set |url| to "http://www.apple.com"
hostname for |url|
-->"www.apple.com"
set |url| to "http://www.macscripter.net/new"
hostname for |url|
-->"www.macscripter.net"
on hostname for |url|
return (|url| as URL)'s host's DNS form
end hostname