Url. resolve Method in node. js instructions for use _ node. js

Source: Internet
Author: User
This article mainly introduces node. url in js. the resolve method is described in this article. resolve Method description, syntax, receiving parameters, use instances and implementation source code. For more information, see Method description:

Insert or replace the original tag for the URL or href. (You can see the example if you don't understand it)

Syntax:

The Code is as follows:


Url. resolve (from,)

Because this method belongs to the url module, You need to introduce the url module (var url = require ("url") before use "))

Receiving parameters:

From Source Address

To tag to be added or replaced

Example:

The Code is as follows:


Var url = require ('url ');
Var a = url. resolve ('/one/two/three', 'four '),
B = url. resolve ('HTTP: // example.com/','/one '),
C = url. resolve ('HTTP: // example.com/one', '/two ');
Console. log (a + "," + B + "," + c );
// Output result:
/// One/two/four
// Http://example.com/one
// Http://example.com/two

Source code:

The Code is as follows:


Url. prototype. resolve = function (relative ){
Return this. resolveObject (urlParse (relative, false, true). format ();
};

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.