1 | # vim: set fileencoding=utf-8 :
|
---|
2 |
|
---|
3 | from django.http import HttpResponse
|
---|
4 | from django.core.validators import URLValidator, ValidationError
|
---|
5 |
|
---|
6 | def go(request):
|
---|
7 | # @see http://www.rooftopsolutions.nl/blog/internationalized-domain-names-are-you-ready
|
---|
8 | tests = (u'http://www.yahoo.com',
|
---|
9 | u'http://yahoo.com',
|
---|
10 | u'http://sãopaulo.com/',
|
---|
11 | u'http://sãopaulo.com.br/',
|
---|
12 | u'http://пример.испытание/',
|
---|
13 | u'http://مثال.إختبار/',
|
---|
14 | u'http://例子.测试/',
|
---|
15 | u'http://例子.測試/',
|
---|
16 | u'http://उदाहरण.परीक्षा/',
|
---|
17 | u'http://例え.テスト/',
|
---|
18 | u'http://مثال.آزمایشی/',
|
---|
19 | u'http://실례.테스트/',
|
---|
20 | u'http://العربية.idn.icann.org/')
|
---|
21 |
|
---|
22 | resp = u''
|
---|
23 |
|
---|
24 | vali = URLValidator()
|
---|
25 | for t in tests:
|
---|
26 | try:
|
---|
27 | vali(t)
|
---|
28 | resp += u'<li>%s OK</li>' % t
|
---|
29 | except ValidationError:
|
---|
30 | resp += u'<li style="color:red; font-weight:bold;">%s FAILED VALIDATION</li>' % t
|
---|
31 |
|
---|
32 | return HttpResponse(resp)
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|