mirror of
https://gitlab.com/soapbox-pub/mkstack.git
synced 2026-12-06 08:47:23 +00:00
Skip client tag on localhost, *.localhost, and IP addresses
This commit is contained in:
1 file changed
+5
-1
@@ -21,8 +21,12 @@ export function useNostrPublish(): UseMutationResult<
|
|||||||
if (user) {
|
if (user) {
|
||||||
const tags = t.tags ?? [];
|
const tags = t.tags ?? [];
|
||||||
|
|
||||||
|
const { hostname } = location;
|
||||||
|
const isLocalhost = hostname === "localhost" || hostname.endsWith(".localhost");
|
||||||
|
const isIpAddress = /^\d{1,3}(\.\d{1,3}){3}$/.test(hostname) || hostname.startsWith("[");
|
||||||
|
|
||||||
// Add the client tag if it doesn't exist
|
// Add the client tag if it doesn't exist
|
||||||
if (location.protocol === "https:" && !tags.some(([name]) => name === "client")) {
|
if (location.protocol === "https:" && !isLocalhost && !isIpAddress && !tags.some(([name]) => name === "client")) {
|
||||||
tags.push(["client", location.hostname]);
|
tags.push(["client", location.hostname]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user