mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-01-22 15:08:12 -05:00
24 lines
1.1 KiB
CoffeeScript
24 lines
1.1 KiB
CoffeeScript
chai = require 'chai'
|
|
should = chai.should()
|
|
Utils = require '../src/utils'
|
|
|
|
describe 'getBaseDomain', ->
|
|
{getBaseDomain} = Utils
|
|
it 'should return domains with zero level unchanged', ->
|
|
getBaseDomain('someinternaldomain').should.equal('someinternaldomain')
|
|
it 'should return domains with one level unchanged', ->
|
|
getBaseDomain('example.com').should.equal('example.com')
|
|
getBaseDomain('e.test').should.equal('e.test')
|
|
getBaseDomain('a.b').should.equal('a.b')
|
|
it 'should treat two-segment TLD as one component', ->
|
|
getBaseDomain('images.google.co.uk').should.equal('google.co.uk')
|
|
getBaseDomain('images.google.co.jp').should.equal('google.co.jp')
|
|
getBaseDomain('example.com.cn').should.equal('example.com.cn')
|
|
it 'should not mistake short domains with two-segment TLDs', ->
|
|
getBaseDomain('a.bc.com').should.equal('bc.com')
|
|
getBaseDomain('i.t.co').should.equal('t.co')
|
|
it 'should not try to modify IP address literals', ->
|
|
getBaseDomain('127.0.0.1').should.equal('127.0.0.1')
|
|
getBaseDomain('[::1]').should.equal('[::1]')
|
|
getBaseDomain('::f').should.equal('::f')
|