温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/node/url/resolve
点击访问原文链接

Node url.resolve function | API Reference | Bun

Node url.resolve function | API Reference | BunBuildDocsReferenceGuidesBlogDiscord/node:url/resolveFresolve

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/node:url/resolveFresolve

function

url.resolvefunction resolve(from: string,to: string): string;The url.resolve() method resolves a target URL relative to a base URL in a manner similar to that of a web browser resolving an anchor tag.

import url from 'node:url'; url.resolve('/one/two/three', 'four'); // '/one/two/four' url.resolve('http://example.com/', '/one'); // 'http://example.com/one' url.resolve('http://example.com/one', '/two'); // 'http://example.com/two' To achieve the same result using the WHATWG URL API:

function resolve(from, to) { const resolvedUrl = new URL(to, new URL(from, 'resolve:http://')); if (resolvedUrl.protocol === 'resolve:') { // `from` is a relative URL. const { pathname, search, hash } = resolvedUrl; return pathname + search + hash; } return resolvedUrl.toString(); } resolve('/one/two/three', 'four'); // '/one/two/four' resolve('http://example.com/', '/one'); // 'http://example.com/one' resolve('http://example.com/one', '/two'); // 'http://example.com/two' @param fromThe base URL to use if to is a relative URL.

@param toThe target URL to resolve.

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco

We're hiring →

智能索引记录