Skip to content

Commit

Permalink
Fix domain normalization while adding manual proxy
Browse files Browse the repository at this point in the history
ruihildt committed Dec 11, 2024
1 parent 95b3e7a commit 14ef03a
Showing 2 changed files with 9 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/components/Proxy/CustomProxies.vue
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import FeGlobe from '@/components/Icons/FeGlobe.vue';
import SplitButton from '@/components/Buttons/SplitButton.vue';
import TitleCategory from '@/components/TitleCategory.vue';
import { isValidDomain } from '@/helpers/domain';
import { isValidDomain, normalizeToFQDN } from '@/helpers/domain';
import useSocksProxy from '@/composables/useSocksProxy';
import useLocations from '@/composables/useLocations';
@@ -41,9 +41,9 @@ const combinedHosts = computed(() => {
});
const handleCustomProxySelectManual = () => {
if (inputProxyDomain.value && isValidDomain(inputProxyDomain.value)) {
const hostname = new URL(inputProxyDomain.value).hostname;
proxySelect(hostname);
const normalizedDomain = normalizeToFQDN(inputProxyDomain.value);
if (normalizedDomain && isValidDomain(normalizedDomain)) {
proxySelect(normalizedDomain);
inputProxyDomainError.value = false;
} else {
inputProxyDomainError.value = true;
5 changes: 5 additions & 0 deletions src/helpers/domain.ts
Original file line number Diff line number Diff line change
@@ -23,3 +23,8 @@ export const getTargetHost = (host: string, proxyDetails: Record<string, ProxyDe
const { hasSubdomain, domain } = checkDomain(host);
return hasSubdomain && domain && proxyDetails[domain] ? domain : host;
};

export const normalizeToFQDN = (input: string): string | null => {
const parsed = parse(input);
return parsed.hostname || null;
};

0 comments on commit 14ef03a

Please sign in to comment.