mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-02-06 04:13:36 +01:00
Merge pull request #3775 from sfabel/master
update domainFormat validation to accept single character domains like c.im
This commit is contained in:
commit
0c4b49cc1d
@ -2,6 +2,13 @@ import { domainFormat } from '@/utils/validator'
|
||||
|
||||
describe('validator', () => {
|
||||
describe('domainFormat', () => {
|
||||
describe('single character domain name', () => {
|
||||
const domain = 'c.im'
|
||||
it('should match', () => {
|
||||
const res = domain.search(domainFormat)
|
||||
expect(res).toEqual(0)
|
||||
})
|
||||
})
|
||||
describe('string contains protocol', () => {
|
||||
const domain = 'https://mastodon.social'
|
||||
it('should not match', () => {
|
||||
|
@ -1 +1,2 @@
|
||||
export const domainFormat = /^[a-zA-Z0-9][a-zA-Z0-9-.]{0,61}[a-zA-Z0-9]\.[a-zA-Z0-9]{2,}$/
|
||||
// eslint-disable-next-line
|
||||
export const domainFormat = /^(((?!\-))(xn\-\-)?[a-z0-9\-_]{0,61}[a-z0-9]{1,1}\.)*(xn\-\-)?([a-z0-9\-]{1,61}|[a-z0-9\-]{1,30})\.[a-z]{2,}$/
|
||||
|
Loading…
x
Reference in New Issue
Block a user