diff --git a/src/core/client/embed/decorators/withSetCommentID.ts b/src/core/client/embed/decorators/withSetCommentID.ts index b7f0ddc9e..c656fca8a 100644 --- a/src/core/client/embed/decorators/withSetCommentID.ts +++ b/src/core/client/embed/decorators/withSetCommentID.ts @@ -1,6 +1,6 @@ import qs from "query-string"; -import { buildURL } from "../utils"; +import { buildURL } from "talk-framework/utils"; import { Decorator } from "./types"; function getCurrentCommentID() { diff --git a/src/core/client/embed/utils/buildURL.spec.ts b/src/core/client/embed/utils/buildURL.spec.ts deleted file mode 100644 index 07e4e2ddc..000000000 --- a/src/core/client/embed/utils/buildURL.spec.ts +++ /dev/null @@ -1,18 +0,0 @@ -import buildURL from "./buildURL"; - -it("should default to window.location", () => { - const url = buildURL(); - expect(url).toBe("http://localhost/"); -}); - -it("should build from parameters", () => { - const url = buildURL({ - protocol: "https", - hostname: "hostname", - port: "8080", - pathname: "/pathname", - search: "search", - hash: "#hash", - }); - expect(url).toBe("https//hostname:8080/pathname?search#hash"); -}); diff --git a/src/core/client/embed/utils/buildURL.ts b/src/core/client/embed/utils/buildURL.ts deleted file mode 100644 index 77353427f..000000000 --- a/src/core/client/embed/utils/buildURL.ts +++ /dev/null @@ -1,17 +0,0 @@ -export default function buildURL({ - protocol = window.location.protocol, - hostname = window.location.hostname, - port = window.location.port, - pathname = window.location.pathname, - search = window.location.search, - hash = window.location.hash, -} = {}) { - if (search && search[0] !== "?") { - search = `?${search}`; - } else if (search === "?") { - search = ""; - } - return `${protocol}//${hostname}${ - port ? `:${port}` : "" - }${pathname}${search}${hash}`; -} diff --git a/src/core/client/embed/utils/index.ts b/src/core/client/embed/utils/index.ts index 13c551665..72a2c8889 100644 --- a/src/core/client/embed/utils/index.ts +++ b/src/core/client/embed/utils/index.ts @@ -1,4 +1,2 @@ -export { default as buildURL } from "./buildURL"; export { default as startsWith } from "./startsWith"; export { default as prefixStorage } from "./prefixStorage"; -export { default as parseHashQuery } from "./parseHashQuery"; diff --git a/src/core/client/embed/utils/parseHashQuery.spec.ts b/src/core/client/embed/utils/parseHashQuery.spec.ts deleted file mode 100644 index c90e0be9e..000000000 --- a/src/core/client/embed/utils/parseHashQuery.spec.ts +++ /dev/null @@ -1,24 +0,0 @@ -import parseHashQuery from "./parseHashQuery"; - -it("should parse hash", () => { - const testCases: Array<[string, ReturnType]> = [ - [ - "#commentID=comment-id", - { - commentID: "comment-id", - }, - ], - [ - "#commentID=comment-id&storyURL=story-url", - { - commentID: "comment-id", - storyURL: "story-url", - }, - ], - ["#", {}], - ["", {}], - ]; - testCases.forEach(tc => { - expect(parseHashQuery(tc[0])).toEqual(tc[1]); - }); -}); diff --git a/src/core/client/embed/utils/parseHashQuery.ts b/src/core/client/embed/utils/parseHashQuery.ts deleted file mode 100644 index daf5f5a5a..000000000 --- a/src/core/client/embed/utils/parseHashQuery.ts +++ /dev/null @@ -1,5 +0,0 @@ -import qs from "query-string"; - -export default function parseQueryHash(hash: string): Record { - return qs.parse(hash); -}