Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CaosDB Crawler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue 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
caosdb
Software
CaosDB Crawler
Commits
2a43219d
Commit
2a43219d
authored
9 months ago
by
Florian Spreckelsen
Browse files
Options
Downloads
Patches
Plain Diff
FIX: Respect context-root and make links platform independent
parent
718b3095
No related branches found
No related tags found
2 merge requests
!181
Release 0.9.0
,
!179
F fix url formatting
Pipeline
#54519
passed
9 months ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caoscrawler/utils.py
+7
-2
7 additions, 2 deletions
src/caoscrawler/utils.py
unittests/test_utilities.py
+4
-0
4 additions, 0 deletions
unittests/test_utilities.py
with
11 additions
and
2 deletions
src/caoscrawler/utils.py
+
7
−
2
View file @
2a43219d
...
@@ -25,9 +25,9 @@
...
@@ -25,9 +25,9 @@
# Some utility functions, e.g. for extending pylib.
# Some utility functions, e.g. for extending pylib.
import
os
import
sys
import
sys
from
posixpath
import
join
as
posixjoin
from
typing
import
Optional
from
typing
import
Optional
from
urllib.parse
import
urljoin
from
urllib.parse
import
urljoin
...
@@ -81,4 +81,9 @@ def get_shared_resource_link(host_url, filename):
...
@@ -81,4 +81,9 @@ def get_shared_resource_link(host_url, filename):
"""
"""
return
urljoin
(
host_url
,
os
.
path
.
join
(
"
/Shared/
"
,
filename
))
if
not
host_url
.
endswith
(
'
/
'
):
# Fill with trailing '/' s. that urljoin doesn't remove the context root.
host_url
+=
'
/
'
# Use posixjoin to always have '/' in links, even when running on
# Windows systems.
return
urljoin
(
host_url
,
posixjoin
(
"
Shared/
"
,
filename
))
This diff is collapsed.
Click to expand it.
unittests/test_utilities.py
+
4
−
0
View file @
2a43219d
...
@@ -76,3 +76,7 @@ def test_shared_resource_link():
...
@@ -76,3 +76,7 @@ def test_shared_resource_link():
"
https://example.com
"
,
"
file.txt
"
)
==
"
https://example.com/Shared/file.txt
"
"
https://example.com
"
,
"
file.txt
"
)
==
"
https://example.com/Shared/file.txt
"
assert
get_shared_resource_link
(
assert
get_shared_resource_link
(
"
https://example.com
"
,
"
path/to/file.txt
"
)
==
"
https://example.com/Shared/path/to/file.txt
"
"
https://example.com
"
,
"
path/to/file.txt
"
)
==
"
https://example.com/Shared/path/to/file.txt
"
assert
get_shared_resource_link
(
"
https://example.com/context-root
"
,
"
path/to/file.txt
"
)
==
"
https://example.com/context-root/Shared/path/to/file.txt
"
assert
get_shared_resource_link
(
"
https://example.com/context-root/
"
,
"
path/to/file.txt
"
)
==
"
https://example.com/context-root/Shared/path/to/file.txt
"
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