ag-common 0.0.498 → 0.0.500
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;
|
|
@@ -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;
|
|
@@ -37,7 +38,8 @@ exports.getRenderLanguage = getRenderLanguage;
|
|
|
37
38
|
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);
|
|
42
|
+
url = (0, url_1.stripUrl)(nu);
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
if (typeof navigator !== 'undefined') {
|
|
@@ -5,7 +5,19 @@ export declare const getNextAppRequest: ({ headers, }: {
|
|
|
5
5
|
get: (s: string) => string | null;
|
|
6
6
|
};
|
|
7
7
|
}) => {
|
|
8
|
-
url:
|
|
8
|
+
url: {
|
|
9
|
+
hash: string;
|
|
10
|
+
host: string;
|
|
11
|
+
hostname: string;
|
|
12
|
+
href: string;
|
|
13
|
+
origin: string;
|
|
14
|
+
password: string;
|
|
15
|
+
pathname: string;
|
|
16
|
+
port: string;
|
|
17
|
+
protocol: string;
|
|
18
|
+
search: string;
|
|
19
|
+
username: string;
|
|
20
|
+
};
|
|
9
21
|
query: Record<string, string>;
|
|
10
22
|
userAgent: string;
|
|
11
23
|
lang: import("../..").TLang;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getNextAppRequest = void 0;
|
|
4
4
|
const object_1 = require("../../common/helpers/object");
|
|
5
|
+
const url_1 = require("../../common/helpers/string/url");
|
|
5
6
|
const routes_1 = require("./routes");
|
|
6
7
|
/** next13 server only */
|
|
7
8
|
const getNextAppRequest = ({ headers, }) => {
|
|
@@ -21,7 +22,7 @@ const getNextAppRequest = ({ headers, }) => {
|
|
|
21
22
|
}
|
|
22
23
|
const cookieDocument = headers.get('cookie');
|
|
23
24
|
return {
|
|
24
|
-
url: new URL(url),
|
|
25
|
+
url: (0, url_1.stripUrl)(new URL(url)),
|
|
25
26
|
query,
|
|
26
27
|
userAgent,
|
|
27
28
|
lang: (0, routes_1.getRenderLanguage)(host),
|
package/package.json
CHANGED