2.0.0 • Published 5 months ago

@saekitominaga/report-same-referrer v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

Send referrer error information to endpoints

npm version test status

If there are referrers from same site, that information will be sent to the endpoint as an error.

As a practical use case, this script put this script in error pages like 403, 404, 410 error pages to detect the existence of broken links in the same site.

Demo

Examples

import ReportSameReferrer from '@saekitominaga/report-same-referrer';

const reportSameReferrer = new ReportSameReferrer('https://report.example.com/referrer', {
  fetchParam: {
    location: 'loc',
    referrer: 'ref',
  },
  fetchContentType: 'application/json',
  fetchHeaders: {
    'X-Requested-With': 'hoge',
  },
  condition: 'origin',
  same: [
    'https://www1.example.com',
    'https://www2.example.com',
  ],
  denyUAs: [
    /Googlebot\/2.1;/,
  ],
});
await reportSameReferrer.report();

Constructor

new ReportSameReferrer(endpoint: string, options?: Option)

Parameters

Option

interface Option {
  fetchParam?: {
    location: string;
    referrer: string;
  };
  fetchContentType?: 'application/x-www-form-urlencoded' | 'application/json';
  fetchHeaders?: HeadersInit;
  condition?: 'origin' | 'host' | 'hostname';
  same?: string[];
  denyUAs?: RegExp[];
  allowUAs?: RegExp[];
}
2.0.0

5 months ago

1.2.1

1 year ago

1.2.0

1 year ago

1.1.1

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.0

3 years ago

1.0.0

3 years ago