Methode Beschreibung:
Sagen Sie eine URL -String, die in ein Objekt konvertiert und zurückgegeben wurde.
Grammatik:
Die Codekopie lautet wie folgt:
url.parse (urlstr, [parsexystring], [slashesdenotehost])
Parameter empfangen:
URLSTR URL -Zeichenfolge
Wenn Parsexystring wahr ist, wird das Abfragemodul zur Analyse der standardmäßigen Abfragezeichenfolge verwendet.
Slashesdenotehost
Standard ist falsch, und eine Zeichenfolge in der Form von // foo/bar wird als {pathname: '// foo/bar'} interpretiert
Wenn Sie auf True gesetzt sind, wird die Zeichenfolge von // Foo/Bar als {Host: 'Foo', Pathname: '/Bar'} interpretiert
Beispiel:
Die Codekopie lautet wie folgt: var url = require ('url');
var a = url.parse ('http://example.com:8080/one?a=Index&t=Article&m=default');
console.log (a);
// Ausgabeergebnis:
{
Protokoll: 'Http',
AUTH: NULL,
Host: 'Beispiel.com:8080',
Port: '8080',
Hostname: 'Beispiel.com',
Hash: Null,
Suche: '? a = index & t = article & m = Standard',
Abfrage: 'a = Index & t = Artikel & M = Standard',
Pfadname: '/eins',
Pfad: '/ein? a = index & t = article & m = Standard',
href: 'http://example.com:8080/one?a=Index&t=Article&m=default'
}