Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

nsIURLParser

Specifies the interface to an URL parser that attempts to follow the definitions of RFC 2396.
Inherits from: nsISupports Last changed in Gecko 1.7

Method overview

void parseAuthority(in string authority, in long authorityLen, out unsigned long usernamePos, out long usernameLen, out unsigned long passwordPos, out long passwordLen, out unsigned long hostnamePos, out long hostnameLen, out long port);
void parseFileName(in string filename, in long filenameLen, out unsigned long basenamePos, out long basenameLen, out unsigned long extensionPos, out long extensionLen);
void parseFilePath(in string filepath, in long filepathLen, out unsigned long directoryPos, out long directoryLen, out unsigned long basenamePos, out long basenameLen, out unsigned long extensionPos, out long extensionLen);
void parsePath(in string path, in long pathLen, out unsigned long filepathPos, out long filepathLen, out unsigned long paramPos, out long paramLen, out unsigned long queryPos, out long queryLen, out unsigned long refPos, out long refLen);
void parseServerInfo(in string serverinfo, in long serverinfoLen, out unsigned long hostnamePos, out long hostnameLen, out long port);
void parseURL(in string spec, in long specLen, out unsigned long schemePos, out long schemeLen, out unsigned long authorityPos, out long authorityLen, out unsigned long pathPos, out long pathLen);
void parseUserInfo(in string userinfo, in long userinfoLen, out unsigned long usernamePos, out long usernameLen, out unsigned long passwordPos, out long passwordLen);

Methods

The string to parse in the methods may be given as a null terminated string, in which case the length argument should be -1.

Out parameters of the methods are all optional (that is the caller may pass-in a null value if the corresponding results are not needed). Signed out parameters may hold a value of -1 if the corresponding result is not part of the string being parsed.

The parsing routines attempt to be as forgiving as possible.

parseAuthority()

Breaks the authority string up into its 4 components: username, password, hostname, and hostport.

auth = <username>:<password>@<hostname>:<port>

void parseAuthority(
  in string authority,
  in long authorityLen,
  out unsigned long usernamePos,
  out long usernameLen,
  out unsigned long passwordPos,
  out long passwordLen,
  out unsigned long hostnamePos,
  out long hostnameLen,
  out long port
);
Parameters
authority
authorityLen
usernamePos
usernameLen
passwordPos
passwordLen
hostnamePos
hostnameLen
port

parseFileName()

filename = <basename>.<extension>

void parseFileName(
  in string filename,
  in long filenameLen,
  out unsigned long basenamePos,
  out long basenameLen,
  out unsigned long extensionPos,
  out long extensionLen
);
Parameters
filename
filenameLen
basenamePos
basenameLen
extensionPos
extensionLen

parseFilePath()

Breaks the file path string up into: the directory portion, file base name, and file extension.

filepath = <directory><basename>.<extension>

void parseFilePath(
  in string filepath,
  in long filepathLen,
  out unsigned long directoryPos,
  out long directoryLen,
  out unsigned long basenamePos,
  out long basenameLen,
  out unsigned long extensionPos,
  out long extensionLen
);
Parameters
filepath
filepathLen
directoryPos
directoryLen
basenamePos
basenameLen
extensionPos
extensionLen

parsePath()

Breaks the path string up into its 4 major components: a file path, a param string, a query string, and a reference string.

path = <filepath>;<param>?<query>#<ref>

void parsePath(
  in string path,
  in long pathLen,
  out unsigned long filepathPos,
  out long filepathLen,
  out unsigned long paramPos, // Removed in Gecko 9.0
  out long paramLen, // Removed in Gecko 9.0
  out unsigned long queryPos,
  out long queryLen,
  out unsigned long refPos,
  out long refLen
);
Parameters
path
pathLen
filepathPos
filepathLen
paramPos Obsolete since Gecko 9.0
paramLen Obsolete since Gecko 9.0
queryPos
queryLen
refPos
refLen

parseServerInfo()

serverinfo = <hostname>:<port>

void parseServerInfo(
  in string serverinfo,
  in long serverinfoLen,
  out unsigned long hostnamePos,
  out long hostnameLen,
  out long port
);
Parameters
serverinfo
serverinfoLen
hostnamePos
hostnameLen
port

parseURL()

Breaks the URL string up into its 3 major components: a scheme, an authority section (hostname, and so on.), and a path.

spec = <scheme>://<authority><path>

void parseURL(
  in string spec,
  in long specLen,
  out unsigned long schemePos,
  out long schemeLen,
  out unsigned long authorityPos,
  out long authorityLen,
  out unsigned long pathPos,
  out long pathLen
);
Parameters
spec
specLen
schemePos
schemeLen
authorityPos
authorityLen
pathPos
pathLen

parseUserInfo()

userinfo = <username>:<password>

void parseUserInfo(
  in string userinfo,
  in long userinfoLen,
  out unsigned long usernamePos,
  out long usernameLen,
  out unsigned long passwordPos,
  out long passwordLen
);
Parameters
userinfo
userinfoLen
usernamePos
usernameLen
passwordPos
passwordLen

Notes

Starting in Gecko 9.0 (Firefox 9.0 / Thunderbird 9.0 / SeaMonkey 2.6), this no longer treats the semicolon as a "parameter string" marker. This was never a valid part of a URL, and is now no longer supported. This makes URLs with semicolons in them work correctly.

Document Tags and Contributors

 Contributors to this page: Sheppy, trevorh
 Last updated by: Sheppy,