@standardserver/core 0.0.4 → 0.0.5

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.mts CHANGED
@@ -68,6 +68,11 @@ declare function generateContentDisposition(filename: string): string;
68
68
  declare function getFilenameFromContentDisposition(contentDisposition: string): string | undefined;
69
69
  declare function flattenStandardHeader(header: string | readonly string[] | undefined): string | undefined;
70
70
  declare function mergeStandardHeaders(a: StandardHeaders, b: StandardHeaders): StandardHeaders;
71
+ declare function parseStandardUrl(url: StandardUrl): [
72
+ pathname: `/${string}`,
73
+ search: `?${string}` | undefined,
74
+ hash: `#${string}` | undefined
75
+ ];
71
76
 
72
- export { flattenStandardHeader, generateContentDisposition, getFilenameFromContentDisposition, mergeStandardHeaders };
77
+ export { flattenStandardHeader, generateContentDisposition, getFilenameFromContentDisposition, mergeStandardHeaders, parseStandardUrl };
73
78
  export type { StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl };
package/dist/index.d.ts CHANGED
@@ -68,6 +68,11 @@ declare function generateContentDisposition(filename: string): string;
68
68
  declare function getFilenameFromContentDisposition(contentDisposition: string): string | undefined;
69
69
  declare function flattenStandardHeader(header: string | readonly string[] | undefined): string | undefined;
70
70
  declare function mergeStandardHeaders(a: StandardHeaders, b: StandardHeaders): StandardHeaders;
71
+ declare function parseStandardUrl(url: StandardUrl): [
72
+ pathname: `/${string}`,
73
+ search: `?${string}` | undefined,
74
+ hash: `#${string}` | undefined
75
+ ];
71
76
 
72
- export { flattenStandardHeader, generateContentDisposition, getFilenameFromContentDisposition, mergeStandardHeaders };
77
+ export { flattenStandardHeader, generateContentDisposition, getFilenameFromContentDisposition, mergeStandardHeaders, parseStandardUrl };
73
78
  export type { StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl };
package/dist/index.mjs CHANGED
@@ -41,5 +41,16 @@ function mergeStandardHeaders(a, b) {
41
41
  }
42
42
  return merged;
43
43
  }
44
+ function parseStandardUrl(url) {
45
+ const hashStart = url.indexOf("#");
46
+ const searchStart = url.indexOf("?");
47
+ const hasSearchBeforeHash = searchStart !== -1 && (hashStart === -1 || searchStart < hashStart);
48
+ const pathnameEnd = hasSearchBeforeHash ? searchStart : hashStart !== -1 ? hashStart : url.length;
49
+ const searchEnd = hashStart !== -1 ? hashStart : url.length;
50
+ const pathname = url.slice(0, pathnameEnd);
51
+ const search = hasSearchBeforeHash ? url.slice(searchStart, searchEnd) : void 0;
52
+ const hash = hashStart !== -1 ? url.slice(hashStart) : void 0;
53
+ return [pathname, search, hash];
54
+ }
44
55
 
45
- export { flattenStandardHeader, generateContentDisposition, getFilenameFromContentDisposition, mergeStandardHeaders };
56
+ export { flattenStandardHeader, generateContentDisposition, getFilenameFromContentDisposition, mergeStandardHeaders, parseStandardUrl };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@standardserver/core",
3
3
  "type": "module",
4
- "version": "0.0.4",
4
+ "version": "0.0.5",
5
5
  "license": "MIT",
6
6
  "homepage": "https://standardserver.dev",
7
7
  "repository": {
@@ -25,7 +25,7 @@
25
25
  "dist"
26
26
  ],
27
27
  "dependencies": {
28
- "@standardserver/shared": "0.0.4"
28
+ "@standardserver/shared": "0.0.5"
29
29
  },
30
30
  "scripts": {
31
31
  "build": "unbuild",