billy-herrington-utils 2.0.2 → 2.0.3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "billy-herrington-utils",
3
3
  "description": "daddy told us not to be ashamed of our utils",
4
- "version": "2.0.2",
4
+ "version": "2.0.3",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "utils",
@@ -39,7 +39,6 @@ export class PaginationStrategyPathnameParams extends PaginationStrategy {
39
39
  const links = getPaginationLinks(
40
40
  (this.getPaginationElement() || document) as HTMLElement,
41
41
  this.url.href,
42
- true,
43
42
  this.pathnameSelector,
44
43
  );
45
44
  const pages = Array.from(links, this.extractPage);
@@ -6,11 +6,11 @@ export function parseURL(s: HTMLAnchorElement | Location | URL | string): URL {
6
6
  export function getPaginationLinks(
7
7
  doc: Element | HTMLElement | Document = document,
8
8
  url: Location | URL | string = location.href,
9
- pathnameStrict = true,
10
9
  pathnameSelector = /\/(page\/)?\d+\/?$/,
11
10
  ): string[] {
12
11
  const currentUrl = parseURL(url);
13
12
  currentUrl.pathname = currentUrl.pathname.replace(pathnameSelector, '/');
13
+ const pathnameStrict = doc instanceof Document;
14
14
 
15
15
  const pageLinks = Array.from(
16
16
  (doc.querySelectorAll('a[href]') as NodeListOf<HTMLAnchorElement>) || [],
@@ -19,7 +19,6 @@ export function getPaginationLinks(
19
19
  try {
20
20
  const linkUrl = new URL(h.replace(/#\w*$/, ''), doc.baseURI || currentUrl.origin);
21
21
  return (
22
- // in case of origin sometimes it's protocols problem cause some links can be not https but http
23
22
  linkUrl.hostname === currentUrl.hostname &&
24
23
  (pathnameStrict ? linkUrl.pathname.startsWith(currentUrl.pathname) : true)
25
24
  );