8000 Plug.Static is too sensitive for different paths writing · Issue #118 · wookay/Bukdu.jl · GitHub
[go: up one dir, main page]

Skip to content

Plug.Static is too sensitive for different paths writing #118

Open

Description

@rssdev10

Plug.Static is not providing proper errors.

using Bukdu

routes() do
    # correct way
    plug(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 result
    plug(Plug.Static, at="//static3", from=pwd())
end

Bukdu.start(8080)

Activity

  1. wookay commented on Sep 16, 2022

    @wookay
    Owner

    please don't use the pwd() to specify the from directory.
    and what's the meaning about //?

  2. rssdev10 commented on Sep 16, 2022

    @rssdev10
    Author

    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.

  3. rssdev10 commented on Sep 16, 2022

    @rssdev10
    Author

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0