mirror of
https://github.com/tabler/tabler.git
synced 2026-10-12 21:27:06 +04:00
27 lines
824 B
TypeScript
27 lines
824 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { isExternal } from './url'
|
|
|
|
describe('isExternal', () => {
|
|
it('is true for absolute http(s) urls', () => {
|
|
expect(isExternal('https://tabler.io')).toBe(true)
|
|
expect(isExternal('http://example.com/page')).toBe(true)
|
|
})
|
|
|
|
it('is false for relative urls and anchors', () => {
|
|
expect(isExternal('./dashboard')).toBe(false)
|
|
expect(isExternal('dashboard.html')).toBe(false)
|
|
expect(isExternal('#section')).toBe(false)
|
|
})
|
|
|
|
it('is false for undefined and empty values', () => {
|
|
expect(isExternal(undefined)).toBe(false)
|
|
expect(isExternal('')).toBe(false)
|
|
})
|
|
})
|
|
|
|
describe('isExternal (anchored)', () => {
|
|
it('is false when http(s) appears mid-string', () => {
|
|
expect(isExternal('/redirect?to=https://example.com')).toBe(false)
|
|
})
|
|
})
|