In Phoenixframework I want to know full URL path that is being requested so I tried to use <%= @conn.request_path %>
.
The problem is that I'm requesting :/spa.html#pageone
and I'm getting only /spa.html
.
What is the correct way of also getting the #fragment
identifier part of it?
Asked
Active
Viewed 1,989 times
5

Paulo Janeiro
- 3,181
- 4
- 28
- 46
-
The part after the `#` is called the `fragment identifier` if that helps you search your docs. – John Hascall Jan 08 '16 at 22:28
-
Isn't the # a comment in the phoenix-framework? just a guess but is con.request_post a thing? – kpie Jan 08 '16 at 22:33
-
@JohnHascall Thank you for that! – Paulo Janeiro Jan 08 '16 at 22:38
-
@kpie. Yes, it is the Elixir comment symbol, but in the request is the fragment identifier (as John Hascall pointed out). `conn.request_post` doesn't exist (I'm getting an error). – Paulo Janeiro Jan 08 '16 at 22:40
-
Where can I find a list of methods applicable to conn? – kpie Jan 08 '16 at 22:53
-
@kpie Here:https://hexdocs.pm/plug/extra-readme.html#The-Plug-Conn – Paulo Janeiro Jan 08 '16 at 22:58
-
Is the host variable public? Honestly I'm probably not the guy to answer your question... – kpie Jan 08 '16 at 23:01
-
@kpie I don't know...Thanks anyway. – Paulo Janeiro Jan 08 '16 at 23:04
1 Answers
8
The fragment is not available on the server side.
From RFC2396
When a URI reference is used to perform a retrieval action on the identified resource, the optional fragment identifier, separated from the URI by a crosshatch ("#") character, consists of additional reference information to be interpreted by the user agent after the retrieval action has been successfully completed. As such, it is not part of a URI, but is often used in conjunction with a URI.
You can access it in JavaScript with window.location.hash
.