@@ -21,24 +21,24 @@ const memoize = require("./util/memoize");
2121
2222/**
2323 * @typedef {{
24- * (context: Context, path: string, request: string, resolveContext: ResolveContext, callback: ResolveCallback): void,
25- * (context: Context, path: string, request: string, callback: ResolveCallback): void,
26- * (path: string, request: string, resolveContext: ResolveContext, callback: ResolveCallback): void,
27- * (path: string, request: string, callback: ResolveCallback): void,
24+ * (context: Context, path: string | URL , request: string | URL , resolveContext: ResolveContext, callback: ResolveCallback): void,
25+ * (context: Context, path: string | URL , request: string | URL , callback: ResolveCallback): void,
26+ * (path: string | URL , request: string | URL , resolveContext: ResolveContext, callback: ResolveCallback): void,
27+ * (path: string | URL , request: string | URL , callback: ResolveCallback): void,
2828 * }} ResolveFunctionAsync
2929 */
3030
3131/**
3232 * @typedef {{
33- * (context: Context, path: string, request: string, resolveContext?: ResolveContext): string | false,
34- * (path: string, request: string, resolveContext?: ResolveContext): string | false,
33+ * (context: Context, path: string | URL , request: string | URL , resolveContext?: ResolveContext): string | false,
34+ * (path: string | URL , request: string | URL , resolveContext?: ResolveContext): string | false,
3535 * }} ResolveFunction
3636 */
3737
3838/**
3939 * @typedef {{
40- * (context: Context, path: string, request: string, resolveContext?: ResolveContext): Promise<string | false>,
41- * (path: string, request: string, resolveContext?: ResolveContext): Promise<string | false>,
40+ * (context: Context, path: string | URL , request: string | URL , resolveContext?: ResolveContext): Promise<string | false>,
41+ * (path: string | URL , request: string | URL , resolveContext?: ResolveContext): Promise<string | false>,
4242 * }} ResolveFunctionPromise
4343 */
4444
@@ -70,14 +70,14 @@ const getAsyncResolver = memoize(() =>
7070 */
7171const resolve =
7272 /**
73- * @param {object | string } context context
74- * @param {string } path path
75- * @param {string | ResolveContext | ResolveCallback } request request
73+ * @param {object | string | URL } context context
74+ * @param {string | URL } path path
75+ * @param {string | URL | ResolveContext | ResolveCallback } request request
7676 * @param {ResolveContext | ResolveCallback= } resolveContext resolve context
7777 * @param {ResolveCallback= } callback callback
7878 */
7979 ( context , path , request , resolveContext , callback ) => {
80- if ( typeof context === "string" ) {
80+ if ( typeof context === "string" || context instanceof URL ) {
8181 callback = /** @type {ResolveCallback } */ ( resolveContext ) ;
8282 resolveContext = /** @type {ResolveContext } */ ( request ) ;
8383 request = path ;
@@ -110,14 +110,14 @@ const getSyncResolver = memoize(() =>
110110 */
111111const resolveSync =
112112 /**
113- * @param {object | string } context context
114- * @param {string } path path
115- * @param {string | ResolveContext | undefined } request request
113+ * @param {object | string | URL } context context
114+ * @param {string | URL } path path
115+ * @param {string | URL | ResolveContext | undefined } request request
116116 * @param {ResolveContext= } resolveContext resolve context
117117 * @returns {string | false } resolved path
118118 */
119119 ( context , path , request , resolveContext ) => {
120- if ( typeof context === "string" ) {
120+ if ( typeof context === "string" || context instanceof URL ) {
121121 resolveContext = /** @type {ResolveContext } */ ( request ) ;
122122 request = path ;
123123 path = context ;
@@ -136,14 +136,14 @@ const resolveSync =
136136 */
137137const resolvePromise =
138138 /**
139- * @param {object | string } context context
140- * @param {string } path path
141- * @param {string | ResolveContext | undefined } request request
139+ * @param {object | string | URL } context context
140+ * @param {string | URL } path path
141+ * @param {string | URL | ResolveContext | undefined } request request
142142 * @param {ResolveContext= } resolveContext resolve context
143143 * @returns {Promise<string | false> } resolved path
144144 */
145145 ( context , path , request , resolveContext ) => {
146- if ( typeof context === "string" ) {
146+ if ( typeof context === "string" || context instanceof URL ) {
147147 resolveContext = /** @type {ResolveContext } */ ( request ) ;
148148 request = path ;
149149 path = context ;
@@ -169,14 +169,14 @@ function create(options) {
169169 ...options ,
170170 } ) ;
171171 /**
172- * @param {object | string } context Custom context
173- * @param {string } path Base path
174- * @param {string | ResolveContext | ResolveCallback } request String to resolve
172+ * @param {object | string | URL } context Custom context
173+ * @param {string | URL } path Base path
174+ * @param {string | URL | ResolveContext | ResolveCallback } request String to resolve
175175 * @param {ResolveContext | ResolveCallback= } resolveContext Resolve context
176176 * @param {ResolveCallback= } callback Result callback
177177 */
178178 return function create ( context , path , request , resolveContext , callback ) {
179- if ( typeof context === "string" ) {
179+ if ( typeof context === "string" || context instanceof URL ) {
180180 callback = /** @type {ResolveCallback } */ ( resolveContext ) ;
181181 resolveContext = /** @type {ResolveContext } */ ( request ) ;
182182 request = path ;
@@ -207,14 +207,14 @@ function createSync(options) {
207207 ...options ,
208208 } ) ;
209209 /**
210- * @param {object | string } context custom context
211- * @param {string } path base path
212- * @param {string | ResolveContext | undefined } request request to resolve
210+ * @param {object | string | URL } context custom context
211+ * @param {string | URL } path base path
212+ * @param {string | URL | ResolveContext | undefined } request request to resolve
213213 * @param {ResolveContext= } resolveContext Resolve context
214214 * @returns {string | false } Resolved path or false
215215 */
216216 return function createSync ( context , path , request , resolveContext ) {
217- if ( typeof context === "string" ) {
217+ if ( typeof context === "string" || context instanceof URL ) {
218218 resolveContext = /** @type {ResolveContext } */ ( request ) ;
219219 request = path ;
220220 path = context ;
@@ -239,14 +239,14 @@ function createPromise(options) {
239239 ...options ,
240240 } ) ;
241241 /**
242- * @param {object | string } context Custom context
243- * @param {string } path Base path
244- * @param {string | ResolveContext | undefined } request String to resolve
242+ * @param {object | string | URL } context Custom context
243+ * @param {string | URL } path Base path
244+ * @param {string | URL | ResolveContext | undefined } request String to resolve
245245 * @param {ResolveContext= } resolveContext Resolve context
246246 * @returns {Promise<string | false> } resolved path
247247 */
248248 return function createPromise ( context , path , request , resolveContext ) {
249- if ( typeof context === "string" ) {
249+ if ( typeof context === "string" || context instanceof URL ) {
250250 resolveContext = /** @type {ResolveContext } */ ( request ) ;
251251 request = path ;
252252 path = context ;
0 commit comments