Skip to content

Commit

Permalink
Fix "ResolvePhysicalPath" again, thanks to @generalmarty
Browse files Browse the repository at this point in the history
  • Loading branch information
jczic committed Nov 25, 2019
1 parent 5b9e4a2 commit 4e530d7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion MicroWebSrv2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
print()
print(' ---------------------------')
print(' - Python pkg MicroWebSrv2 -')
print(' - version 2.0.3 -')
print(' - version 2.0.4 -')
print(' - by JC`zic & HC2 -')
print(' ---------------------------')
print()
Expand Down
15 changes: 6 additions & 9 deletions MicroWebSrv2/microWebSrv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,19 +257,16 @@ def ResolvePhysicalPath(self, urlPath) :
raise ValueError('"urlPath" must be a not empty string.')
try :
physPath = self._rootPath + urlPath.replace('..', '/')
if physPath.endswith('/') :
physPath = physPath[:-1]
if MicroWebSrv2._physPathIsDir(physPath) :
if not physPath.endswith('/') :
physPath += '/'
for filename in MicroWebSrv2._DEFAULT_PAGES :
p = physPath + filename
p = physPath + '/' + filename
if MicroWebSrv2._physPathExists(p) :
return p
return physPath
elif not physPath.endswith('/') :
return physPath
return physPath
except :
pass
return None
return None

# ------------------------------------------------------------------------

Expand Down Expand Up @@ -477,7 +474,7 @@ def RootPath(self, value) :
if not isinstance(value, str) or len(value) == 0 :
raise ValueError('"RootPath" must be a not empty string.')
self._validateChangeConf('"RootPath"')
self._rootPath = value
self._rootPath = (value[:-1] if value.endswith('/') else value)

# ------------------------------------------------------------------------

Expand Down

0 comments on commit 4e530d7

Please sign in to comment.