Branch: Tag:

2001-01-30

2001-01-30 22:04:40 by Johan Sundström <oyasumi@gmail.com>

Added some URI hacker's docs of the raw_uri property, cleaned up
reparse_uri minutely and (oops) trimmed some whitespace.

Rev: lib/modules/Standards.pmod/URI.pike:1.8

3:      // Implemented by Johan Sundström and Johan Schön.   // Copyright (c) Roxen Internet Software 2001 - // $Id: URI.pike,v 1.7 2001/01/26 14:54:31 jhs Exp $ + // $Id: URI.pike,v 1.8 2001/01/30 22:04:40 jhs Exp $      #pragma strict_types   
32:   //! The base URI object, if present   object(this_program) base_uri;    + // URI hacker docs: + // This string is the raw uri the object was instantiated from in the + // first place. We save it here for the sole purpose of being able to + // replace the base URI, hence also needing to reresolve all of our + // properties with respect to that change.   string raw_uri;      #define error(S) throw( ({ (S), backtrace() }) )
55:    DEBUG("parse_authority(): host=%O, port=%O", host, port);   }    -  +    // Inherit all properties except raw_uri and base_uri from the URI uri. :-)   static void inherit_properties(object(this_program) uri)   {
101:    if(segments[i]==".")    segments[i]=0;    -  segments -= ({0}); +  segments -= ({ 0 });       // d) If the buffer string ends with "." as a complete path segment,    // that "." is removed.
174:    // 1) The URI reference is parsed into the potential four components and    // fragment identifier, as described in Section 4.3.    -  +     // 2) If the path component is empty and the scheme, authority, and    // query components are undefined, then it is a reference to the    // current document and we are done. Otherwise, the reference URI's    // query and fragment components are defined as found (or not found)    // within the URI reference and not inherited from the base URI.    // (Doing this at once saves us some useless parsing efforts.) -  if(!raw_uri || raw_uri == "") +  if(!uri || uri == "")    {    DEBUG("Path is empty -- Inherit entire base URI "    "as per RFC 2396, §5.2 step 2. Done!");
189:    return;    }    -  if(raw_uri[0] == '#') +  if(uri[0] == '#')    {    DEBUG("Fragment only. Using entire base URI, except fragment.");    inherit_properties(local::base_uri); -  fragment=raw_uri[1..]; +  fragment = uri[1..];    return;    }