@cspell/url 10.4.0-alpha.1 → 10.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,14 +1,11 @@
1
- //#region src/dataUrl.d.mts
2
1
  /**
3
2
  * Try to determine the base name of a URL.
4
3
  * @param url
5
4
  * @returns the base name of a URL, including the trailing `/` if present.
6
5
  */
7
- declare function urlBasename(url: string | URL): string;
8
- declare function isDataURL(url: string | URL): boolean;
9
- //#endregion
10
- //#region src/defaultFileUrlBuilder.d.mts
11
- declare function encodePathChars(filepath: string): string;
6
+ export declare function urlBasename(url: string | URL): string;
7
+ export declare function isDataURL(url: string | URL): boolean;
8
+ export declare function encodePathChars(filepath: string): string;
12
9
  /**
13
10
  * Normalize a file path for use in a URL.
14
11
  * ```js
@@ -18,7 +15,7 @@ declare function encodePathChars(filepath: string): string;
18
15
  * @param filePath
19
16
  * @returns a normalized file path for use as a relative path in a URL.
20
17
  */
21
- declare function normalizeFilePathForUrl(filePath: string): string;
18
+ export declare function normalizeFilePathForUrl(filePath: string): string;
22
19
  /**
23
20
  * Try to make a file URL.
24
21
  * - if filenameOrUrl is already a URL, it is returned as is.
@@ -27,28 +24,24 @@ declare function normalizeFilePathForUrl(filePath: string): string;
27
24
  * @param relativeTo - optional URL, if given, filenameOrUrl will be parsed as relative.
28
25
  * @returns a URL
29
26
  */
30
- declare function toFileURL(filenameOrUrl: string | URL, relativeTo?: string | URL): URL;
27
+ export declare function toFileURL(filenameOrUrl: string | URL, relativeTo?: string | URL): URL;
31
28
  /**
32
29
  * Converts a file path to a URL and adds a trailing slash.
33
30
  * @param dir - url to a directory
34
31
  * @returns a URL
35
32
  */
36
- declare function toFileDirURL(dir: string | URL): URL;
37
- //#endregion
38
- //#region src/fileUrl.d.mts
33
+ export declare function toFileDirURL(dir: string | URL): URL;
39
34
  /**
40
35
  * @param url - URL or string to check if it is a file URL.
41
36
  * @returns true if the URL is a file URL.
42
37
  */
43
- declare function isFileURL(url: URL | string): boolean;
38
+ export declare function isFileURL(url: URL | string): boolean;
44
39
  /**
45
40
  * Convert a URL into a string. If it is a file URL, convert it to a path.
46
41
  * @param url - URL
47
42
  * @returns path or href
48
43
  */
49
- declare function toFilePathOrHref(url: URL | string): string;
50
- //#endregion
51
- //#region src/FileUrlBuilder.d.mts
44
+ export declare function toFilePathOrHref(url: URL | string): string;
52
45
  interface ParsedPath {
53
46
  /**
54
47
  * The root of the path such as '/' or 'c:\'
@@ -84,7 +77,7 @@ interface BuilderOptions {
84
77
  path?: PathInterface | undefined;
85
78
  cwd?: URL | undefined;
86
79
  }
87
- declare class FileUrlBuilder {
80
+ export declare class FileUrlBuilder {
88
81
  #private;
89
82
  private windows;
90
83
  readonly path: PathInterface;
@@ -148,22 +141,20 @@ declare class FileUrlBuilder {
148
141
  isAbsolute(filePath: string): boolean;
149
142
  isUrlLike(url: string | URL): boolean;
150
143
  }
151
- //#endregion
152
- //#region src/url.d.mts
153
144
  /**
154
145
  * Try to make a URL.
155
146
  * @param url
156
147
  * @param relativeTo - optional URL, if given, url will be parsed as relative.
157
148
  * @returns a URL
158
149
  */
159
- declare function toURL(url: string | URL, relativeTo?: string | URL): URL;
150
+ export declare function toURL(url: string | URL, relativeTo?: string | URL): URL;
160
151
  /**
161
152
  * Try to determine the parent directory URL of the uri.
162
153
  * If it is not a hierarchical URL, then it will return the URL.
163
154
  * @param url - url to extract the dirname from.
164
155
  * @returns a URL
165
156
  */
166
- declare function urlParent(url: string | URL): URL;
157
+ export declare function urlParent(url: string | URL): URL;
167
158
  /**
168
159
  * Alias of {@link urlParent}
169
160
  * Try to determine the parent directory URL of the uri.
@@ -171,49 +162,49 @@ declare function urlParent(url: string | URL): URL;
171
162
  * @param url - url to extract the dirname from.
172
163
  * @returns a URL
173
164
  */
174
- declare const urlDirname: typeof urlParent;
165
+ export declare const urlDirname: typeof urlParent;
175
166
  /**
176
167
  * return the basename (last portion of the URL pathname) of a path. It does NOT remove the trailing slash.
177
168
  * @param path - URL pathname to extract the basename from.
178
169
  */
179
- declare function basenameOfUrlPathname(path: string): string;
170
+ export declare function basenameOfUrlPathname(path: string): string;
180
171
  /**
181
172
  * @param filename - filename to check if it is a string containing a URL.
182
173
  */
183
- declare function isUrlLike(filename: string): boolean;
184
- declare function isUrlLike(filename: URL): true;
174
+ export declare function isUrlLike(filename: string): boolean;
175
+ export declare function isUrlLike(filename: URL): true;
185
176
  /**
186
177
  * @param filename - filename to check if it is a string containing a URL or a URL object.
187
178
  */
188
- declare function isUrlLike(filename: string | URL): boolean;
179
+ export declare function isUrlLike(filename: string | URL): boolean;
189
180
  /**
190
181
  * @param filename - filename to check if it is a string containing a URL.
191
182
  */
192
- declare function isNotUrlLike(filename: string): boolean;
193
- declare function isNotUrlLike(filename: URL): false;
183
+ export declare function isNotUrlLike(filename: string): boolean;
184
+ export declare function isNotUrlLike(filename: URL): false;
194
185
  /**
195
186
  * @param filename - filename to check if it is a string containing a URL or a URL object.
196
187
  */
197
- declare function isNotUrlLike(filename: string | URL): filename is string;
188
+ export declare function isNotUrlLike(filename: string | URL): filename is string;
198
189
  /**
199
190
  * Check if `url` is a URL instance.
200
191
  * @returns
201
192
  */
202
- declare function isURL(url: unknown): url is URL;
193
+ export declare function isURL(url: unknown): url is URL;
203
194
  /**
204
195
  *
205
196
  * @param url - url to check
206
197
  * @param protocol - protocol to check against - e.g. 'file:', 'http:', 'https:'
207
198
  * @returns
208
199
  */
209
- declare function hasProtocol(url: string | URL, protocol: string): boolean;
200
+ export declare function hasProtocol(url: string | URL, protocol: string): boolean;
210
201
  /**
211
202
  * Attempts to add a trailing slash to the URL pathname if it does not already have one.
212
203
  * Some If the pathname doesn't start with a `/`, a trailing slash is not added.
213
204
  * @param url - a URL
214
205
  * @returns
215
206
  */
216
- declare function addTrailingSlash(url: URL): URL;
207
+ export declare function addTrailingSlash(url: URL): URL;
217
208
  /**
218
209
  * Calculate the relative path to go from `urlFrom` to `urlTo`.
219
210
  * The protocol is not evaluated. Only the `url.pathname` is used.
@@ -221,20 +212,19 @@ declare function addTrailingSlash(url: URL): URL;
221
212
  * @param urlTo
222
213
  * @returns the relative path
223
214
  */
224
- declare function urlRelative(urlFrom: string | URL, urlTo: string | URL): string;
215
+ export declare function urlRelative(urlFrom: string | URL, urlTo: string | URL): string;
225
216
  /**
226
217
  * Ensure that a windows file url is correctly formatted with a capitol letter for the drive.
227
218
  *
228
219
  * @param url - URL to check.
229
220
  * @returns a new URL if modified or converted from a string.
230
221
  */
231
- declare function normalizeWindowsUrl(url: URL | string): URL;
222
+ export declare function normalizeWindowsUrl(url: URL | string): URL;
232
223
  /**
233
224
  * There is a bug is NodeJS that sometimes causes UNC paths converted to a URL to be prefixed with `file:////`.
234
225
  * @param url - URL to check.
235
226
  * @returns fixed URL if needed.
236
227
  */
237
- declare function fixUncUrl(url: URL): URL;
238
- //#endregion
239
- export { type BuilderOptions, FileUrlBuilder, type PathInterface, addTrailingSlash, basenameOfUrlPathname, encodePathChars, fixUncUrl, hasProtocol, isDataURL, isFileURL, isNotUrlLike, isURL, isUrlLike, normalizeFilePathForUrl, normalizeWindowsUrl, toFileDirURL, toFilePathOrHref, toFileURL, toURL, urlBasename, urlDirname, urlParent, urlRelative };
228
+ export declare function fixUncUrl(url: URL): URL;
229
+ export type { BuilderOptions, PathInterface };
240
230
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import assert from "node:assert";
2
2
  import Path from "node:path";
3
3
  import { fileURLToPath, pathToFileURL } from "node:url";
4
- //#region src/url.mts
4
+ // src/url.mts
5
5
  const isURLRegEx = /^(\w[\w-]{1,63}:\/|data:|stdin:)/i;
6
6
  /**
7
7
  * Try to make a URL.
@@ -145,8 +145,7 @@ function fixUncUrl(url) {
145
145
  if (url.href.startsWith("file:////")) return new URL(url.href.replace(/^file:\/{4}/, "file://"));
146
146
  return url;
147
147
  }
148
- //#endregion
149
- //#region src/dataUrl.mts
148
+ // src/dataUrl.mts
150
149
  const regMatchFilename = /filename=([^;,]*)/;
151
150
  /**
152
151
  * Try to determine the base name of a URL.
@@ -166,8 +165,7 @@ function urlBasename(url) {
166
165
  function isDataURL(url) {
167
166
  return hasProtocol(url, "data:");
168
167
  }
169
- //#endregion
170
- //#region src/fileUrl.mts
168
+ // src/fileUrl.mts
171
169
  const isWindows = process.platform === "win32";
172
170
  const windowsUrlPathRegExp = /^\/[a-zA-Z]:\//;
173
171
  function isWindowsPathnameWithDriveLatter(pathname) {
@@ -234,8 +232,7 @@ function fixLongPathPrefix(path) {
234
232
  if (!hasLongPathPrefixAlt(path)) return path;
235
233
  return uncLongPathPrefix + path.slice(4);
236
234
  }
237
- //#endregion
238
- //#region src/FileUrlBuilder.mts
235
+ // src/FileUrlBuilder.mts
239
236
  const isWindowsPathRegEx = regExpWindowsPathDriveLetter;
240
237
  const isWindowsPathname = regExpWindowsPath;
241
238
  const percentRegEx = /%/g;
@@ -410,8 +407,7 @@ var FileUrlBuilder = class {
410
407
  return isUrlLike(url);
411
408
  }
412
409
  };
413
- //#endregion
414
- //#region src/defaultFileUrlBuilder.mts
410
+ // src/defaultFileUrlBuilder.mts
415
411
  const fileUrlBuilder = new FileUrlBuilder();
416
412
  function encodePathChars(filepath) {
417
413
  return fileUrlBuilder.encodePathChars(filepath);
@@ -447,7 +443,6 @@ function toFileURL(filenameOrUrl, relativeTo) {
447
443
  function toFileDirURL(dir) {
448
444
  return fileUrlBuilder.toFileDirURL(dir);
449
445
  }
450
- //#endregion
451
446
  export { FileUrlBuilder, addTrailingSlash, basenameOfUrlPathname, encodePathChars, fixUncUrl, hasProtocol, isDataURL, isFileURL, isNotUrlLike, isURL, isUrlLike, normalizeFilePathForUrl, normalizeWindowsUrl, toFileDirURL, toFilePathOrHref, toFileURL, toURL, urlBasename, urlDirname, urlParent, urlRelative };
452
447
 
453
448
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cspell/url",
3
- "version": "10.4.0-alpha.1",
3
+ "version": "10.4.1",
4
4
  "description": "URL parsing and manipulation utilities for cspell",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -57,5 +57,5 @@
57
57
  "engines": {
58
58
  "node": ">=22.18.0"
59
59
  },
60
- "gitHead": "628768a6e62b792e628189b41e63e12e5d3d8fe3"
60
+ "gitHead": "ddb1699a4bfc2766675c2c97412a813d775772eb"
61
61
  }