Skip to content

Commit e24816d

Browse files
Merge pull request #45 from dnslink-std/feat/fragment-domain-detection
feat: use URL fragment as domain
2 parents 14e4de8 + dde0e0a commit e24816d

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

components/try-dnslink.vue

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,18 @@ export default defineComponent({
360360
setup () {
361361
const defaultDomain = 'en.wikipedia-on-ipfs.org'
362362
const running = ref(false)
363-
const domain = ref(defaultDomain)
363+
364+
// Check for domain in URL fragment (e.g., #example.com)
365+
const fragmentDomain = typeof window !== 'undefined' && window.location.hash
366+
? window.location.hash.slice(1).trim()
367+
: ''
368+
369+
// Only use fragment if it looks like a DNS name (contains at least one dot)
370+
const initialDomain = fragmentDomain && fragmentDomain.includes('.')
371+
? fragmentDomain
372+
: defaultDomain
373+
374+
const domain = ref(initialDomain)
364375
const advanced = ref(false)
365376
const endpoints = ref<string[]>([FALLBACK_ENDPOINT])
366377
wellknown.data().then(

0 commit comments

Comments
 (0)