Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
http-server
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefane Fermigier
http-server
Commits
4d4e9c9b
Commit
4d4e9c9b
authored
Nov 12, 2021
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement URL parser
parent
416ac9dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
src/stdlib/url.pxd
src/stdlib/url.pxd
+58
-0
No files found.
src/stdlib/url.pxd
0 → 100644
View file @
4d4e9c9b
from
stdlib.string
cimport
Str
cdef
cypclass
URI
:
Str
full
Str
scheme
Str
authority
Str
path
Str
query
Str
fragment
__init__
(
self
,
Str
uri
):
self
.
full
=
uri
self
.
parse
(
uri
)
void
parse
(
self
,
Str
uri
):
cdef
int
pos
=
0
cdef
int
nxt
cdef
Str
COLUMN
=
Str
(
':'
)
cdef
Str
SLASH
=
Str
(
'/'
)
cdef
Str
SLASHSLASH
=
SLASH
+
SLASH
cdef
Str
QUERY
=
Str
(
'?'
)
cdef
Str
FRAGMENT
=
Str
(
'#'
)
nxt
=
uri
.
find
(
COLUMN
,
pos
)
if
nxt
!=
-
1
:
self
.
scheme
=
uri
.
substr
(
pos
,
nxt
)
pos
=
nxt
+
COLUMN
.
__len__
()
if
uri
.
find
(
SLASHSLASH
,
pos
,
pos
+
SLASHSLASH
.
__len__
())
!=
-
1
:
pos
=
nxt
+
SLASHSLASH
.
__len__
()
nxt
=
uri
.
find
(
SLASH
,
pos
)
if
nxt
==
-
1
:
nxt
=
uri
.
find
(
QUERY
,
pos
)
if
nxt
==
-
1
:
nxt
=
uri
.
find
(
FRAGMENT
,
pos
)
if
nxt
==
-
1
:
self
.
authority
=
uri
.
substr
(
pos
)
return
self
.
authority
=
uri
.
substr
(
pos
,
nxt
)
pos
=
nxt
nxt
=
uri
.
find
(
QUERY
,
pos
)
if
nxt
==
-
1
:
nxt
=
uri
.
find
(
FRAGMENT
,
pos
)
if
nxt
>
pos
:
self
.
path
=
uri
.
substr
(
pos
,
nxt
)
elif
nxt
==
-
1
:
self
.
path
=
uri
.
substr
(
pos
)
return
else
:
if
nxt
>
pos
:
self
.
path
=
uri
.
substr
(
pos
,
nxt
)
pos
=
nxt
+
QUERY
.
__len__
()
nxt
=
uri
.
find
(
FRAGMENT
,
pos
)
if
nxt
==
-
1
:
self
.
query
=
uri
.
substr
(
pos
)
return
self
.
query
=
uri
.
substr
(
pos
,
nxt
)
pos
=
nxt
+
FRAGMENT
.
__len__
()
self
.
fragment
=
uri
.
substr
(
pos
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment