Search code examples
angularjsurlserverhref

Empty href tag returns current url on remote server


I left a few href tags without values. However after deploying the application to a remote server, those tags get filled with the url corresponding to the app location on that server.

So, if my application lived at http://www.foo.org/, href = "" gets replaced with href = "http://www.foo.org/".

Why?


Solution

  • This is by design.

    According to RFC 2396:

    A URI reference that does not contain a URI is a reference to the current document. In other words, an empty URI reference within a document is interpreted as a reference to the start of that document, and a reference containing only a fragment identifier is a reference to the identified fragment of that document. Traversal of such a reference should not result in an additional retrieval action. However, if the URI reference occurs in a context that is always intended to result in a new request, as in the case of HTML's FORM element, then an empty URI reference represents the base URI of the current document and should be replaced by that URI when transformed into a request.