ag-common 0.0.499 → 0.0.501

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.
@@ -7,3 +7,16 @@ export interface ISite {
7
7
  */
8
8
  export declare const niceUrl: (siteUrl: string) => ISite | undefined;
9
9
  export declare function isValidUrl(raw: string): boolean;
10
+ export declare const stripUrl: (nu: URL) => {
11
+ hash: string;
12
+ host: string;
13
+ hostname: string;
14
+ href: string;
15
+ origin: string;
16
+ password: string;
17
+ pathname: string;
18
+ port: string;
19
+ protocol: string;
20
+ search: string;
21
+ username: string;
22
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isValidUrl = exports.niceUrl = void 0;
3
+ exports.stripUrl = exports.isValidUrl = exports.niceUrl = void 0;
4
4
  const trim_1 = require("./trim");
5
5
  /**
6
6
  * removes protocol, and trailing slashes
@@ -28,3 +28,17 @@ function isValidUrl(raw) {
28
28
  }
29
29
  }
30
30
  exports.isValidUrl = isValidUrl;
31
+ const stripUrl = (nu) => ({
32
+ hash: nu.hash,
33
+ host: nu.host,
34
+ hostname: nu.hostname,
35
+ href: nu.href,
36
+ origin: nu.origin,
37
+ password: nu.password,
38
+ pathname: nu.pathname,
39
+ port: nu.port,
40
+ protocol: nu.protocol,
41
+ search: nu.search,
42
+ username: nu.username,
43
+ });
44
+ exports.stripUrl = stripUrl;
@@ -10,7 +10,6 @@ export * from './extractAttributes';
10
10
  export * from './jwt';
11
11
  export * from './plural';
12
12
  export * from './routes';
13
- export * from './routesnext';
14
13
  export * from './serviceWorker';
15
14
  export * from './useContextMenu';
16
15
  export * from './useElementAttribute';
@@ -26,7 +26,6 @@ __exportStar(require("./extractAttributes"), exports);
26
26
  __exportStar(require("./jwt"), exports);
27
27
  __exportStar(require("./plural"), exports);
28
28
  __exportStar(require("./routes"), exports);
29
- __exportStar(require("./routesnext"), exports);
30
29
  __exportStar(require("./serviceWorker"), exports);
31
30
  __exportStar(require("./useContextMenu"), exports);
32
31
  __exportStar(require("./useElementAttribute"), exports);
@@ -4,6 +4,7 @@ exports.getServerReq = exports.getClientOrServerReqHref = exports.getRenderLangu
4
4
  const i18n_1 = require("../../common/helpers/i18n");
5
5
  const object_1 = require("../../common/helpers/object");
6
6
  const object_2 = require("../../common/helpers/string/object");
7
+ const url_1 = require("../../common/helpers/string/url");
7
8
  const calculateServerHref = ({ host, pathname, }) => {
8
9
  if (!host) {
9
10
  return undefined;
@@ -38,19 +39,7 @@ const getClientOrServerReqHref = ({ url, query, forceServer = false, userAgent,
38
39
  if (typeof window !== 'undefined') {
39
40
  if (!forceServer) {
40
41
  const nu = new URL(window.location.href);
41
- url = {
42
- hash: nu.hash,
43
- host: nu.host,
44
- hostname: nu.hostname,
45
- href: nu.href,
46
- origin: nu.origin,
47
- password: nu.password,
48
- pathname: nu.pathname,
49
- port: nu.port,
50
- protocol: nu.protocol,
51
- search: nu.search,
52
- username: nu.username,
53
- };
42
+ url = (0, url_1.stripUrl)(nu);
54
43
  }
55
44
  }
56
45
  if (typeof navigator !== 'undefined') {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.499",
2
+ "version": "0.0.501",
3
3
  "name": "ag-common",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
@@ -1,13 +0,0 @@
1
- /** next13 server only */
2
- export declare const getNextAppRequest: ({ headers, }: {
3
- /** use next/headers() */
4
- headers: {
5
- get: (s: string) => string | null;
6
- };
7
- }) => {
8
- url: URL;
9
- query: Record<string, string>;
10
- userAgent: string;
11
- lang: import("../..").TLang;
12
- cookieDocument: string | null;
13
- };
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getNextAppRequest = void 0;
4
- const object_1 = require("../../common/helpers/object");
5
- const routes_1 = require("./routes");
6
- /** next13 server only */
7
- const getNextAppRequest = ({ headers, }) => {
8
- var _a, _b, _c, _d, _e;
9
- let query = {};
10
- if (headers.get('x-invoke-query')) {
11
- query = JSON.parse(decodeURIComponent((_a = headers.get('x-invoke-query')) !== null && _a !== void 0 ? _a : '{}'));
12
- }
13
- const userAgent = (_c = (_b = headers.get('user-agent')) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== null && _c !== void 0 ? _c : '';
14
- const host = (_d = headers.get('host')) !== null && _d !== void 0 ? _d : '';
15
- const pathname = (_e = headers.get('x-invoke-path')) !== null && _e !== void 0 ? _e : '/';
16
- const protocol = host.includes(':443') || !host.includes(':') ? 'https:' : 'http:';
17
- let url = `${protocol}${host}${pathname}`;
18
- if (Object.keys(query).length > 0) {
19
- const qs = '?' + (0, object_1.objectToString)(query, '=', '&');
20
- url += qs;
21
- }
22
- const cookieDocument = headers.get('cookie');
23
- return {
24
- url: new URL(url),
25
- query,
26
- userAgent,
27
- lang: (0, routes_1.getRenderLanguage)(host),
28
- cookieDocument,
29
- };
30
- };
31
- exports.getNextAppRequest = getNextAppRequest;