feedcanon 0.9.2 → 1.0.0-beta.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/defaults.cjs CHANGED
@@ -18,6 +18,8 @@ const defaultStrippedParams = [
18
18
  "wbraid",
19
19
  "gclsrc",
20
20
  "gad_source",
21
+ "gad_campaignid",
22
+ "srsltid",
21
23
  "fbclid",
22
24
  "fb_action_ids",
23
25
  "fb_action_types",
@@ -60,12 +62,43 @@ const defaultStrippedParams = [
60
62
  "hsa_src",
61
63
  "hsa_tgt",
62
64
  "hsa_ver",
65
+ "hsCtaTracking",
66
+ "__hstc",
67
+ "__hsfp",
68
+ "__hssc",
63
69
  "cid",
64
70
  "s_kwcid",
65
71
  "ef_id",
66
72
  "obOrigUrl",
67
73
  "dicbo",
68
74
  "yclid",
75
+ "awinaffid",
76
+ "awinmid",
77
+ "clickref",
78
+ "afftrack",
79
+ "itm_source",
80
+ "itm_medium",
81
+ "itm_campaign",
82
+ "itm_content",
83
+ "itm_channel",
84
+ "itm_audience",
85
+ "int_source",
86
+ "int_medium",
87
+ "int_campaign",
88
+ "int_content",
89
+ "int_placement",
90
+ "int_campaign_type",
91
+ "int_keycode",
92
+ "g2i_source",
93
+ "g2i_medium",
94
+ "g2i_campaign",
95
+ "g2i_or_o",
96
+ "g2i_or_p",
97
+ "doing_wp_cron",
98
+ "preview",
99
+ "preview_id",
100
+ "preview_nonce",
101
+ "replytocom",
69
102
  "_",
70
103
  "timestamp",
71
104
  "ts",
@@ -74,6 +107,14 @@ const defaultStrippedParams = [
74
107
  "nocache",
75
108
  "rand",
76
109
  "random",
110
+ "forceByPassCache",
111
+ "sucurianticache",
112
+ "cleancache",
113
+ "rebuildcache",
114
+ "kontrol_health_check_timestamp",
115
+ "_x_tr_sl",
116
+ "_x_tr_tl",
117
+ "_x_tr_hl",
77
118
  "action_object_map",
78
119
  "action_ref_map",
79
120
  "action_type_map",
@@ -93,9 +134,6 @@ const defaultStrippedParams = [
93
134
  "hmb_campaign",
94
135
  "hmb_medium",
95
136
  "hmb_source",
96
- "itm_campaign",
97
- "itm_medium",
98
- "itm_source",
99
137
  "ml_subscriber",
100
138
  "ml_subscriber_hash",
101
139
  "oly_anon_id",
@@ -118,7 +156,6 @@ const defaultNormalizeOptions = {
118
156
  stripRootSlash: true,
119
157
  collapseSlashes: true,
120
158
  stripHash: true,
121
- stripTextFragment: true,
122
159
  sortQueryParams: true,
123
160
  stripQueryParams: defaultStrippedParams,
124
161
  stripEmptyQuery: true,
@@ -136,7 +173,6 @@ const defaultTiers = [
136
173
  stripRootSlash: true,
137
174
  collapseSlashes: true,
138
175
  stripHash: true,
139
- stripTextFragment: true,
140
176
  sortQueryParams: true,
141
177
  stripQueryParams: defaultStrippedParams,
142
178
  stripEmptyQuery: true,
@@ -153,7 +189,6 @@ const defaultTiers = [
153
189
  stripRootSlash: true,
154
190
  collapseSlashes: true,
155
191
  stripHash: true,
156
- stripTextFragment: true,
157
192
  sortQueryParams: true,
158
193
  stripQueryParams: defaultStrippedParams,
159
194
  stripEmptyQuery: true,
@@ -170,7 +205,6 @@ const defaultTiers = [
170
205
  stripRootSlash: true,
171
206
  collapseSlashes: true,
172
207
  stripHash: true,
173
- stripTextFragment: true,
174
208
  sortQueryParams: true,
175
209
  stripQueryParams: defaultStrippedParams,
176
210
  stripEmptyQuery: true,
package/dist/defaults.js CHANGED
@@ -18,6 +18,8 @@ const defaultStrippedParams = [
18
18
  "wbraid",
19
19
  "gclsrc",
20
20
  "gad_source",
21
+ "gad_campaignid",
22
+ "srsltid",
21
23
  "fbclid",
22
24
  "fb_action_ids",
23
25
  "fb_action_types",
@@ -60,12 +62,43 @@ const defaultStrippedParams = [
60
62
  "hsa_src",
61
63
  "hsa_tgt",
62
64
  "hsa_ver",
65
+ "hsCtaTracking",
66
+ "__hstc",
67
+ "__hsfp",
68
+ "__hssc",
63
69
  "cid",
64
70
  "s_kwcid",
65
71
  "ef_id",
66
72
  "obOrigUrl",
67
73
  "dicbo",
68
74
  "yclid",
75
+ "awinaffid",
76
+ "awinmid",
77
+ "clickref",
78
+ "afftrack",
79
+ "itm_source",
80
+ "itm_medium",
81
+ "itm_campaign",
82
+ "itm_content",
83
+ "itm_channel",
84
+ "itm_audience",
85
+ "int_source",
86
+ "int_medium",
87
+ "int_campaign",
88
+ "int_content",
89
+ "int_placement",
90
+ "int_campaign_type",
91
+ "int_keycode",
92
+ "g2i_source",
93
+ "g2i_medium",
94
+ "g2i_campaign",
95
+ "g2i_or_o",
96
+ "g2i_or_p",
97
+ "doing_wp_cron",
98
+ "preview",
99
+ "preview_id",
100
+ "preview_nonce",
101
+ "replytocom",
69
102
  "_",
70
103
  "timestamp",
71
104
  "ts",
@@ -74,6 +107,14 @@ const defaultStrippedParams = [
74
107
  "nocache",
75
108
  "rand",
76
109
  "random",
110
+ "forceByPassCache",
111
+ "sucurianticache",
112
+ "cleancache",
113
+ "rebuildcache",
114
+ "kontrol_health_check_timestamp",
115
+ "_x_tr_sl",
116
+ "_x_tr_tl",
117
+ "_x_tr_hl",
77
118
  "action_object_map",
78
119
  "action_ref_map",
79
120
  "action_type_map",
@@ -93,9 +134,6 @@ const defaultStrippedParams = [
93
134
  "hmb_campaign",
94
135
  "hmb_medium",
95
136
  "hmb_source",
96
- "itm_campaign",
97
- "itm_medium",
98
- "itm_source",
99
137
  "ml_subscriber",
100
138
  "ml_subscriber_hash",
101
139
  "oly_anon_id",
@@ -118,7 +156,6 @@ const defaultNormalizeOptions = {
118
156
  stripRootSlash: true,
119
157
  collapseSlashes: true,
120
158
  stripHash: true,
121
- stripTextFragment: true,
122
159
  sortQueryParams: true,
123
160
  stripQueryParams: defaultStrippedParams,
124
161
  stripEmptyQuery: true,
@@ -136,7 +173,6 @@ const defaultTiers = [
136
173
  stripRootSlash: true,
137
174
  collapseSlashes: true,
138
175
  stripHash: true,
139
- stripTextFragment: true,
140
176
  sortQueryParams: true,
141
177
  stripQueryParams: defaultStrippedParams,
142
178
  stripEmptyQuery: true,
@@ -153,7 +189,6 @@ const defaultTiers = [
153
189
  stripRootSlash: true,
154
190
  collapseSlashes: true,
155
191
  stripHash: true,
156
- stripTextFragment: true,
157
192
  sortQueryParams: true,
158
193
  stripQueryParams: defaultStrippedParams,
159
194
  stripEmptyQuery: true,
@@ -170,7 +205,6 @@ const defaultTiers = [
170
205
  stripRootSlash: true,
171
206
  collapseSlashes: true,
172
207
  stripHash: true,
173
- stripTextFragment: true,
174
208
  sortQueryParams: true,
175
209
  stripQueryParams: defaultStrippedParams,
176
210
  stripEmptyQuery: true,
package/dist/index.cjs CHANGED
@@ -2,8 +2,8 @@ const require_defaults = require('./defaults.cjs');
2
2
  const require_utils = require('./utils.cjs');
3
3
 
4
4
  //#region src/index.ts
5
- const findCanonical = async (inputUrl, options) => {
6
- const { fetchFn = require_utils.nativeFetch, existsFn, parser = require_utils.feedsmithParser, tiers = require_defaults.defaultTiers, platforms = require_defaults.defaultPlatforms, onFetch, onMatch, onExists } = options ?? {};
5
+ async function findCanonical(inputUrl, options) {
6
+ const { parser = require_utils.feedsmithParser, fetchFn = require_utils.nativeFetch, existsFn, tiers = require_defaults.defaultTiers, platforms = require_defaults.defaultPlatforms, onFetch, onMatch, onExists } = options ?? {};
7
7
  const resolveAndApplyPlatformHandlers = (url, baseUrl) => {
8
8
  const resolved = require_utils.resolveUrl(url, baseUrl);
9
9
  return resolved ? require_utils.applyPlatformHandlers(resolved, platforms) : void 0;
@@ -125,7 +125,7 @@ const findCanonical = async (inputUrl, options) => {
125
125
  }
126
126
  }
127
127
  return winningUrl;
128
- };
128
+ }
129
129
 
130
130
  //#endregion
131
131
  exports.findCanonical = findCanonical;
package/dist/index.d.cts CHANGED
@@ -1,6 +1,9 @@
1
- import { FeedsmithFeed, FindCanonicalOptions } from "./types.cjs";
1
+ import { FeedsmithFeed, FetchFnResponse, FindCanonicalOptions, ParserAdapter } from "./types.cjs";
2
2
 
3
3
  //#region src/index.d.ts
4
- declare const findCanonical: <TFeed = FeedsmithFeed, TExisting = unknown>(inputUrl: string, options?: FindCanonicalOptions<TFeed, TExisting>) => Promise<string | undefined>;
4
+ declare function findCanonical<TResponse extends FetchFnResponse = FetchFnResponse, TExisting = unknown>(inputUrl: string, options?: Omit<FindCanonicalOptions<FeedsmithFeed, TResponse, TExisting>, 'parser'>): Promise<string | undefined>;
5
+ declare function findCanonical<TFeed, TResponse extends FetchFnResponse = FetchFnResponse, TExisting = unknown>(inputUrl: string, options: FindCanonicalOptions<TFeed, TResponse, TExisting> & {
6
+ parser: ParserAdapter<TFeed>;
7
+ }): Promise<string | undefined>;
5
8
  //#endregion
6
9
  export { findCanonical };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,9 @@
1
- import { FeedsmithFeed, FindCanonicalOptions } from "./types.js";
1
+ import { FeedsmithFeed, FetchFnResponse, FindCanonicalOptions, ParserAdapter } from "./types.js";
2
2
 
3
3
  //#region src/index.d.ts
4
- declare const findCanonical: <TFeed = FeedsmithFeed, TExisting = unknown>(inputUrl: string, options?: FindCanonicalOptions<TFeed, TExisting>) => Promise<string | undefined>;
4
+ declare function findCanonical<TResponse extends FetchFnResponse = FetchFnResponse, TExisting = unknown>(inputUrl: string, options?: Omit<FindCanonicalOptions<FeedsmithFeed, TResponse, TExisting>, 'parser'>): Promise<string | undefined>;
5
+ declare function findCanonical<TFeed, TResponse extends FetchFnResponse = FetchFnResponse, TExisting = unknown>(inputUrl: string, options: FindCanonicalOptions<TFeed, TResponse, TExisting> & {
6
+ parser: ParserAdapter<TFeed>;
7
+ }): Promise<string | undefined>;
5
8
  //#endregion
6
9
  export { findCanonical };
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@ import { defaultPlatforms, defaultTiers } from "./defaults.js";
2
2
  import { applyPlatformHandlers, feedsmithParser, nativeFetch, normalizeUrl, resolveUrl } from "./utils.js";
3
3
 
4
4
  //#region src/index.ts
5
- const findCanonical = async (inputUrl, options) => {
6
- const { fetchFn = nativeFetch, existsFn, parser = feedsmithParser, tiers = defaultTiers, platforms = defaultPlatforms, onFetch, onMatch, onExists } = options ?? {};
5
+ async function findCanonical(inputUrl, options) {
6
+ const { parser = feedsmithParser, fetchFn = nativeFetch, existsFn, tiers = defaultTiers, platforms = defaultPlatforms, onFetch, onMatch, onExists } = options ?? {};
7
7
  const resolveAndApplyPlatformHandlers = (url, baseUrl) => {
8
8
  const resolved = resolveUrl(url, baseUrl);
9
9
  return resolved ? applyPlatformHandlers(resolved, platforms) : void 0;
@@ -125,7 +125,7 @@ const findCanonical = async (inputUrl, options) => {
125
125
  }
126
126
  }
127
127
  return winningUrl;
128
- };
128
+ }
129
129
 
130
130
  //#endregion
131
131
  export { findCanonical };
package/dist/types.d.cts CHANGED
@@ -19,7 +19,6 @@ type NormalizeOptions = {
19
19
  stripRootSlash?: boolean;
20
20
  collapseSlashes?: boolean;
21
21
  stripHash?: boolean;
22
- stripTextFragment?: boolean;
23
22
  sortQueryParams?: boolean;
24
23
  stripQueryParams?: Array<string>;
25
24
  stripEmptyQuery?: boolean;
@@ -28,40 +27,40 @@ type NormalizeOptions = {
28
27
  normalizeUnicode?: boolean;
29
28
  convertToPunycode?: boolean;
30
29
  };
31
- type OnFetchFn = (data: {
30
+ type OnFetchFn<TResponse extends FetchFnResponse = FetchFnResponse> = (data: {
32
31
  url: string;
33
- response: FetchFnResponse;
32
+ response: TResponse;
34
33
  }) => void;
35
- type OnMatchFn<TFeed = unknown> = (data: {
34
+ type OnMatchFn<TFeed = unknown, TResponse extends FetchFnResponse = FetchFnResponse> = (data: {
36
35
  url: string;
37
- response: FetchFnResponse;
36
+ response: TResponse;
38
37
  feed: TFeed;
39
38
  }) => void;
40
39
  type OnExistsFn<T> = (data: {
41
40
  url: string;
42
41
  data: T;
43
42
  }) => void;
44
- type ExistsFn<T = unknown> = (url: string) => Promise<T | undefined>;
45
- type FindCanonicalOptions<TFeed = FeedsmithFeed, TExisting = unknown> = {
43
+ type FindCanonicalOptions<TFeed = FeedsmithFeed, TResponse extends FetchFnResponse = FetchFnResponse, TExisting = unknown> = {
46
44
  parser?: ParserAdapter<TFeed>;
47
- fetchFn?: FetchFn;
45
+ fetchFn?: FetchFn<TResponse>;
48
46
  existsFn?: ExistsFn<TExisting>;
49
47
  tiers?: Array<NormalizeOptions>;
50
48
  platforms?: Array<PlatformHandler>;
51
- onFetch?: OnFetchFn;
52
- onMatch?: OnMatchFn<TFeed>;
49
+ onFetch?: OnFetchFn<TResponse>;
50
+ onMatch?: OnMatchFn<TFeed, TResponse>;
53
51
  onExists?: OnExistsFn<TExisting>;
54
52
  };
55
53
  type FetchFnOptions = {
56
54
  method?: 'GET' | 'HEAD';
57
55
  headers?: Record<string, string>;
58
56
  };
57
+ type ExistsFn<T = unknown> = (url: string) => Promise<T | undefined>;
59
58
  type FetchFnResponse = {
60
59
  headers: Headers;
61
60
  body: string;
62
61
  url: string;
63
62
  status: number;
64
63
  };
65
- type FetchFn = (url: string, options?: FetchFnOptions) => Promise<FetchFnResponse>;
64
+ type FetchFn<TResponse extends FetchFnResponse = FetchFnResponse> = (url: string, options?: FetchFnOptions) => Promise<TResponse>;
66
65
  //#endregion
67
66
  export { ExistsFn, FeedsmithFeed, FetchFn, FetchFnOptions, FetchFnResponse, FindCanonicalOptions, NormalizeOptions, OnExistsFn, OnFetchFn, OnMatchFn, ParserAdapter, PlatformHandler };
package/dist/types.d.ts CHANGED
@@ -19,7 +19,6 @@ type NormalizeOptions = {
19
19
  stripRootSlash?: boolean;
20
20
  collapseSlashes?: boolean;
21
21
  stripHash?: boolean;
22
- stripTextFragment?: boolean;
23
22
  sortQueryParams?: boolean;
24
23
  stripQueryParams?: Array<string>;
25
24
  stripEmptyQuery?: boolean;
@@ -28,40 +27,40 @@ type NormalizeOptions = {
28
27
  normalizeUnicode?: boolean;
29
28
  convertToPunycode?: boolean;
30
29
  };
31
- type OnFetchFn = (data: {
30
+ type OnFetchFn<TResponse extends FetchFnResponse = FetchFnResponse> = (data: {
32
31
  url: string;
33
- response: FetchFnResponse;
32
+ response: TResponse;
34
33
  }) => void;
35
- type OnMatchFn<TFeed = unknown> = (data: {
34
+ type OnMatchFn<TFeed = unknown, TResponse extends FetchFnResponse = FetchFnResponse> = (data: {
36
35
  url: string;
37
- response: FetchFnResponse;
36
+ response: TResponse;
38
37
  feed: TFeed;
39
38
  }) => void;
40
39
  type OnExistsFn<T> = (data: {
41
40
  url: string;
42
41
  data: T;
43
42
  }) => void;
44
- type ExistsFn<T = unknown> = (url: string) => Promise<T | undefined>;
45
- type FindCanonicalOptions<TFeed = FeedsmithFeed, TExisting = unknown> = {
43
+ type FindCanonicalOptions<TFeed = FeedsmithFeed, TResponse extends FetchFnResponse = FetchFnResponse, TExisting = unknown> = {
46
44
  parser?: ParserAdapter<TFeed>;
47
- fetchFn?: FetchFn;
45
+ fetchFn?: FetchFn<TResponse>;
48
46
  existsFn?: ExistsFn<TExisting>;
49
47
  tiers?: Array<NormalizeOptions>;
50
48
  platforms?: Array<PlatformHandler>;
51
- onFetch?: OnFetchFn;
52
- onMatch?: OnMatchFn<TFeed>;
49
+ onFetch?: OnFetchFn<TResponse>;
50
+ onMatch?: OnMatchFn<TFeed, TResponse>;
53
51
  onExists?: OnExistsFn<TExisting>;
54
52
  };
55
53
  type FetchFnOptions = {
56
54
  method?: 'GET' | 'HEAD';
57
55
  headers?: Record<string, string>;
58
56
  };
57
+ type ExistsFn<T = unknown> = (url: string) => Promise<T | undefined>;
59
58
  type FetchFnResponse = {
60
59
  headers: Headers;
61
60
  body: string;
62
61
  url: string;
63
62
  status: number;
64
63
  };
65
- type FetchFn = (url: string, options?: FetchFnOptions) => Promise<FetchFnResponse>;
64
+ type FetchFn<TResponse extends FetchFnResponse = FetchFnResponse> = (url: string, options?: FetchFnOptions) => Promise<TResponse>;
66
65
  //#endregion
67
66
  export { ExistsFn, FeedsmithFeed, FetchFn, FetchFnOptions, FetchFnResponse, FindCanonicalOptions, NormalizeOptions, OnExistsFn, OnFetchFn, OnMatchFn, ParserAdapter, PlatformHandler };
package/dist/utils.cjs CHANGED
@@ -91,7 +91,6 @@ const normalizeUrl = (url, options = require_defaults.defaultNormalizeOptions) =
91
91
  }
92
92
  if (options.stripWww && parsed.hostname.startsWith("www.")) parsed.hostname = parsed.hostname.slice(4);
93
93
  if (options.stripHash) parsed.hash = "";
94
- if (options.stripTextFragment && parsed.hash.startsWith("#:~:")) parsed.hash = "";
95
94
  let pathname = parsed.pathname;
96
95
  if (options.normalizeEncoding) pathname = decodeAndNormalizeEncoding(pathname);
97
96
  if (options.collapseSlashes) pathname = pathname.replace(/\/+/g, "/");
package/dist/utils.js CHANGED
@@ -91,7 +91,6 @@ const normalizeUrl = (url, options = defaultNormalizeOptions) => {
91
91
  }
92
92
  if (options.stripWww && parsed.hostname.startsWith("www.")) parsed.hostname = parsed.hostname.slice(4);
93
93
  if (options.stripHash) parsed.hash = "";
94
- if (options.stripTextFragment && parsed.hash.startsWith("#:~:")) parsed.hash = "";
95
94
  let pathname = parsed.pathname;
96
95
  if (options.normalizeEncoding) pathname = decodeAndNormalizeEncoding(pathname);
97
96
  if (options.collapseSlashes) pathname = pathname.replace(/\/+/g, "/");
package/package.json CHANGED
@@ -60,5 +60,5 @@
60
60
  "kvalita": "1.9.0",
61
61
  "tsdown": "^0.18.2"
62
62
  },
63
- "version": "0.9.2"
63
+ "version": "1.0.0-beta.1"
64
64
  }