Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
DuniterPy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
clients
python
DuniterPy
Commits
48d4373e
Commit
48d4373e
authored
4 years ago
by
Moul
Browse files
Options
Downloads
Patches
Plain Diff
[enh]
#170
: Change domain regex to support IDN
Internationalized domain names Add test
parent
35ea9868
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
duniterpy/constants.py
+5
-1
5 additions, 1 deletion
duniterpy/constants.py
tests/api/test_endpoints.py
+13
-0
13 additions, 0 deletions
tests/api/test_endpoints.py
with
18 additions
and
1 deletion
duniterpy/constants.py
+
5
−
1
View file @
48d4373e
...
...
@@ -40,7 +40,11 @@ IPV6_REGEX = (
f
"
fe80:(?::
{
IPV6SEG
}
){{0,4}}%[0-9a-zA-Z]+|::(?:ffff(?::0{{1,4}})?:)?
{
IPV4_REGEX
}
|
"
f
"
(?:
{
IPV6SEG
}
:){{1,4}}:
{
IPV4_REGEX
}
"
)
HOST_REGEX
=
"
[a-z0-9-_.]*(?:.[a-zA-Z])?
"
# https://stackoverflow.com/a/26987741
HOST_REGEX
=
(
"
(((?!-))(xn--|_)?[a-z0-9-]{0,61}[a-z0-9]
\\
.)*
"
"
(xn--)?([a-z0-9][a-z0-9
\\
-]{0,60}|[a-z0-9-]{1,30}
\\
.[a-z]{2,})
"
)
# https://stackoverflow.com/a/12968117
PORT_REGEX
=
(
"
[1-9]
\\
d{0,3}|0|[1-5]
\\
d{4}|6[0-4]
\\
d{3}|65[0-4]
\\
d{2}|655[0-2]
\\
d|6553[0-5]
"
...
...
This diff is collapsed.
Click to expand it.
tests/api/test_endpoints.py
+
13
−
0
View file @
48d4373e
...
...
@@ -46,6 +46,19 @@ class TestEndpoint(unittest.TestCase):
self
.
assertEqual
(
gva_endpoint
.
inline
(),
endpoint_str
)
endpoint_str
=
"
GVA S xn--duniter.org 10902
"
gva_endpoint
=
endpoint
.
GVAEndpoint
.
from_inline
(
endpoint_str
)
self
.
assertEqual
(
gva_endpoint
.
flags
,
"
S
"
)
self
.
assertEqual
(
gva_endpoint
.
server
,
"
xn--duniter.org
"
)
self
.
assertEqual
(
gva_endpoint
.
ipv4
,
None
)
self
.
assertEqual
(
gva_endpoint
.
ipv6
,
None
)
self
.
assertEqual
(
gva_endpoint
.
port
,
10902
)
self
.
assertEqual
(
gva_endpoint
.
path
,
""
)
self
.
assertEqual
(
gva_endpoint
.
inline
(),
endpoint_str
)
def
test_gva_subscription
(
self
):
endpoint_str
=
"
GVASUB test.domain.com 127.0.0.1 2001:0db8:0000:85a3:0000:0000:ac1f:8001 10902 gva
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment