1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2025-07-23 04:41:16 -04:00

url-parse -> new URL()

This commit is contained in:
2021-11-08 10:52:07 -05:00
parent b1d95a6283
commit d7f90ae4b7
3 changed files with 1 additions and 16 deletions

View File

@@ -1,6 +1,5 @@
import fetch from "cross-fetch";
import canonicalUrl from "get-canonical-url";
import urlParse from "url-parse";
// API endpoint
const HITS_ENDPOINT = "/api/hits/";
@@ -24,7 +23,7 @@ if (wrapper) {
wrapper.style.display = "inline-flex";
// get path and strip beginning and ending forward slash
const slug = urlParse(canonical).pathname.replace(/^\/|\/$/g, "");
const slug = new URL(canonical).pathname.replace(/^\/|\/$/g, "");
fetch(`${HITS_ENDPOINT}?slug=${encodeURIComponent(slug)}`)
.then((response) => response.json())