<
8000
svg aria-hidden="true" data-component="Octicon" height="16" viewBox="0 0 16 16" version="1.1" width="16" data-view-component="true" class="octicon octicon-alert">
You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Plug.Static is too sensitive for different paths writing #118
using Bukdu
routes() do# correct wayplug(Plug.Static, at="/static", from=normpath(joinpath(pwd(),".")))
# wrong - not able to read from subdirs but able to get from current directory only# error in "from" value. For any requested file from subdir, the error 404 is generated.plug(Plug.Static, at="/static2", from=pwd())
# eating symbols from the file name# double slash in front of "at"-value gives an exception as a resultplug(Plug.Static, at="//static3", from=pwd())
end
Bukdu.start(8080)
If I understand right, the from directory must contain . final symbol. That is unclear.
When the path contains a double slash then file names are interpreted without a first symbol. E.g. plug(Plug.Static, at="//static3", from=pwd()) gives an error while requesting "index.html" => /static3/ndex.html without i. Double slash might be occurring when the path was built from multiple strings with partial paths. Anyway that is not an error.
Sorry, my suggestion about the . sign was wrong. When normpath() is gettign something ended by /., the result is ended by /. That is, to fix the issue with from just add inside the code normpath(joinpath(normpath(path), ".")) to avoid confusion. Internal normpath() will remove dot if present. Next joinpath will guarantee that the path contains .. And final normpath gives a path that is always ended by /.
To fix the second issue, either change the calculation of the offset, or add replace(uri_path, r"/{2,}" => '/') inside.
Activity
wookay commentedon Sep 16, 2022
please don't use the
pwd()to specify thefromdirectory.and what's the meaning about
//?rssdev10 commentedon Sep 16, 2022
If I understand right, the
fromdirectory must contain.final symbol. That is unclear.When the path contains a double slash then file names are interpreted without a first symbol. E.g.
plug(Plug.Static, at="//static3", from=pwd())gives an error while requesting "index.html" =>/static3/ndex.htmlwithouti. Double slash might be occurring when the path was built from multiple strings with partial paths. Anyway that is not an error.rssdev10 commentedon Sep 16, 2022
Sorry, my suggestion about the
.sign was wrong. Whennormpath()is gettign something ended by/., the result is ended by/. That is, to fix the issue withfromjust add inside the codenormpath(joinpath(normpath(path), "."))to avoid confusion. Internalnormpath()will remove dot if present. Nextjoinpathwill guarantee that the path contains.. And finalnormpathgives a path that is always ended by/.To fix the second issue, either change the calculation of the offset, or add
replace(uri_path, r"/{2,}" => '/')inside.