@tryghost/referrer-parser 0.1.16 → 0.1.18

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,127 +1,28 @@
1
- /**
2
- * Parse a referrer URL to get source, medium and hostname
3
- *
4
- * @param referrerUrl - URL of the referrer to parse
5
- * @param options - Configuration options
6
- * @param referrerSource - Optional source to override URL parameters
7
- * @param referrerMedium - Optional medium to override URL parameters
8
- * @returns Parsed referrer data with source, medium and URL
9
- *
10
- * @example
11
- * // Basic usage
12
- * const result = parse('https://www.google.com/search?q=ghost+cms');
13
- * // result: { referrerSource: 'Google', referrerMedium: 'search', referrerUrl: 'www.google.com' }
14
- *
15
- * @example
16
- * // With site configuration
17
- * const result = parse('https://example.com/blog?utm_source=newsletter', {
18
- * siteUrl: 'https://example.com'
19
- * });
20
- *
21
- * @example
22
- * // With explicit source and medium
23
- * const result = parse('https://example.com', {}, 'newsletter', 'email');
24
- */
25
- export declare function parse(referrerUrl: string, options?: ParserOptions, referrerSource?: string, referrerMedium?: string): ReferrerData;
26
-
27
- /**
28
- * Configuration options for the parser
29
- */
30
- export declare interface ParserOptions {
31
- /** URL of the site for identifying internal traffic */
32
- siteUrl?: string;
33
- /** URL of the admin panel for identifying admin traffic */
34
- adminUrl?: string;
35
- }
36
-
37
- /**
38
- * Interface for parsed referrer data
39
- */
40
- export declare interface ReferrerData {
41
- /** The identified source of the referral traffic */
42
- referrerSource: string | null;
43
- /** The identified medium of the referral traffic */
44
- referrerMedium: string | null;
45
- /** The hostname of the referral URL */
46
- referrerUrl: string | null;
47
- }
48
-
49
- /**
50
- * Parses referrer URLs to determine source and medium
51
- */
52
- export declare class ReferrerParser {
53
- private adminUrl;
54
- private siteUrl;
55
- /**
56
- * Creates a new referrer parser instance
57
- *
58
- * @param options - Configuration options
59
- */
60
- constructor(options?: ParserOptions);
61
- /**
62
- * Parse a referrer URL to get source, medium and hostname
63
- *
64
- * @param referrerUrlStr - URL of the referrer
65
- * @param referrerSource - Source of the referrer
66
- * @param referrerMedium - Medium of the referrer
67
- * @returns Parsed referrer data with source, medium and URL. Internal referrers return null values.
68
- */
69
- parse(referrerUrlStr: string, referrerSource?: string, referrerMedium?: string): ReferrerData;
70
- /**
71
- * Fetches referrer data from known external URLs
72
- *
73
- * @param url - The URL to match against known referrers
74
- * @returns Matched referrer data or null if not found
75
- */
76
- getDataFromUrl(url: URL | null): ReferrerSourceData | null;
77
- /**
78
- * Return URL object for provided URL string
79
- *
80
- * @param url - URL string to parse
81
- * @returns Parsed URL object or null if invalid
82
- */
83
- getUrlFromStr(url: string): URL | null;
84
- /**
85
- * Determine whether the provided URL is a link to the site
86
- *
87
- * @param url - URL to check
88
- * @returns True if the URL belongs to the configured site
89
- */
90
- isSiteDomain(url: URL | null): boolean;
91
- /**
92
- * Determine whether referrer is a Ghost newsletter
93
- *
94
- * @param deps - Input parameters
95
- * @returns True if the referrer is a Ghost newsletter
96
- */
97
- isGhostNewsletter({ referrerSource }: {
98
- referrerSource: string | null;
99
- }): boolean;
100
- /**
101
- * Determine whether referrer is a Ghost.org URL
102
- *
103
- * @param referrerUrl - The referrer URL to check
104
- * @returns True if the referrer is from Ghost.org
105
- */
106
- isGhostOrgUrl(referrerUrl: URL | null): boolean;
107
- /**
108
- * Determine whether referrer is Ghost Explore
109
- *
110
- * @param deps - Input parameters
111
- * @returns True if the referrer is from Ghost Explore
112
- */
113
- isGhostExploreRef({ referrerUrl, referrerSource }: {
114
- referrerUrl: URL | null;
115
- referrerSource?: string | null;
116
- }): boolean;
117
- }
118
-
119
- /**
120
- * Interface for referrer source data
121
- */
122
- declare interface ReferrerSourceData {
123
- source: string;
124
- medium: string;
125
- }
126
-
127
- export { }
1
+ import { ReferrerParser, ReferrerData, ParserOptions } from './lib/ReferrerParser';
2
+ /**
3
+ * Parse a referrer URL to get source, medium and hostname
4
+ *
5
+ * @param referrerUrl - URL of the referrer to parse
6
+ * @param options - Configuration options
7
+ * @param referrerSource - Optional source to override URL parameters
8
+ * @param referrerMedium - Optional medium to override URL parameters
9
+ * @returns Parsed referrer data with source, medium and URL
10
+ *
11
+ * @example
12
+ * // Basic usage
13
+ * const result = parse('https://www.google.com/search?q=ghost+cms');
14
+ * // result: { referrerSource: 'Google', referrerMedium: 'search', referrerUrl: 'www.google.com' }
15
+ *
16
+ * @example
17
+ * // With site configuration
18
+ * const result = parse('https://example.com/blog?utm_source=newsletter', {
19
+ * siteUrl: 'https://example.com'
20
+ * });
21
+ *
22
+ * @example
23
+ * // With explicit source and medium
24
+ * const result = parse('https://example.com', {}, 'newsletter', 'email');
25
+ */
26
+ declare function parse(referrerUrl: string, options?: ParserOptions, referrerSource?: string, referrerMedium?: string): ReferrerData;
27
+ export { parse, ReferrerParser };
28
+ export type { ReferrerData, ParserOptions };
package/dist/index.js CHANGED
@@ -9534,7 +9534,7 @@ var ReferrerParser = class {
9534
9534
  siteUrl;
9535
9535
  /**
9536
9536
  * Creates a new referrer parser instance
9537
- *
9537
+ *
9538
9538
  * @param options - Configuration options
9539
9539
  */
9540
9540
  constructor(options = {}) {
@@ -9543,7 +9543,7 @@ var ReferrerParser = class {
9543
9543
  }
9544
9544
  /**
9545
9545
  * Parse a referrer URL to get source, medium and hostname
9546
- *
9546
+ *
9547
9547
  * @param referrerUrlStr - URL of the referrer
9548
9548
  * @param referrerSource - Source of the referrer
9549
9549
  * @param referrerMedium - Medium of the referrer
@@ -9599,7 +9599,7 @@ var ReferrerParser = class {
9599
9599
  }
9600
9600
  /**
9601
9601
  * Fetches referrer data from known external URLs
9602
- *
9602
+ *
9603
9603
  * @param url - The URL to match against known referrers
9604
9604
  * @returns Matched referrer data or null if not found
9605
9605
  */
@@ -9615,7 +9615,7 @@ var ReferrerParser = class {
9615
9615
  }
9616
9616
  /**
9617
9617
  * Return URL object for provided URL string
9618
- *
9618
+ *
9619
9619
  * @param url - URL string to parse
9620
9620
  * @returns Parsed URL object or null if invalid
9621
9621
  */
@@ -9623,13 +9623,13 @@ var ReferrerParser = class {
9623
9623
  if (!url) return null;
9624
9624
  try {
9625
9625
  return new URL(url);
9626
- } catch (e) {
9626
+ } catch {
9627
9627
  return null;
9628
9628
  }
9629
9629
  }
9630
9630
  /**
9631
9631
  * Determine whether the provided URL is a link to the site
9632
- *
9632
+ *
9633
9633
  * @param url - URL to check
9634
9634
  * @returns True if the URL belongs to the configured site
9635
9635
  */
@@ -9648,13 +9648,13 @@ var ReferrerParser = class {
9648
9648
  return false;
9649
9649
  }
9650
9650
  return false;
9651
- } catch (e) {
9651
+ } catch {
9652
9652
  return false;
9653
9653
  }
9654
9654
  }
9655
9655
  /**
9656
9656
  * Determine whether referrer is a Ghost newsletter
9657
- *
9657
+ *
9658
9658
  * @param deps - Input parameters
9659
9659
  * @returns True if the referrer is a Ghost newsletter
9660
9660
  */
@@ -9664,7 +9664,7 @@ var ReferrerParser = class {
9664
9664
  }
9665
9665
  /**
9666
9666
  * Determine whether referrer is a Ghost.org URL
9667
- *
9667
+ *
9668
9668
  * @param referrerUrl - The referrer URL to check
9669
9669
  * @returns True if the referrer is from Ghost.org
9670
9670
  */
@@ -9674,7 +9674,7 @@ var ReferrerParser = class {
9674
9674
  }
9675
9675
  /**
9676
9676
  * Determine whether referrer is Ghost Explore
9677
- *
9677
+ *
9678
9678
  * @param deps - Input parameters
9679
9679
  * @returns True if the referrer is from Ghost Explore
9680
9680
  */