File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -48,15 +48,21 @@ class ResourceURL(UserString):
48
48
Behaves as a Python string.
49
49
"""
50
50
51
- def __init__ (self , path : str , external : bool = True ):
51
+ def __init__ (self , path : str , external : bool = True , protocol : str = "" ):
52
52
self .path = path
53
53
self .external = external
54
+ # Strip :// if the user mistakenly included it in the argument
55
+ self .protocol = protocol .rstrip ("://" )
54
56
UserString .__init__ (self , path )
55
57
56
58
@property
57
59
def data (self ):
58
60
if self .external and has_request_context ():
59
61
prefix = request .host_url .rstrip ("/" )
62
+ # Optional protocol override
63
+ if self .protocol :
64
+ # Strip old protocol and replace with custom protocol
65
+ prefix = self .protocol + "://" + prefix .split ("://" )[1 ]
60
66
else :
61
67
prefix = ""
62
68
return prefix + self .path
You can’t perform that action at this time.
0 commit comments