5

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?

Paulo Janeiro
  • 3,181
  • 4
  • 28
  • 46

1 Answers1

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.

gre_gor
  • 6,669
  • 9
  • 47
  • 52
Gazler
  • 83,029
  • 18
  • 279
  • 245