Skip to content

Commit

Permalink
fix: Allow abstract.com domain for share links and expose inferShareId (
Browse files Browse the repository at this point in the history
#217)

* Allow abstract.com domain for share links and expose inferShareId

* Add test for new domain check
  • Loading branch information
anthony-j-castro authored Feb 16, 2020
1 parent a000ca6 commit 7789a92
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow
/* istanbul ignore file */
import Client from "./Client";
import { inferShareId } from "./util/helpers";
import { paginate } from "./paginate";
import * as sketch from "./sketch";
import {
Expand Down Expand Up @@ -31,6 +32,7 @@ export {
ServiceUnavailableError,
UnauthorizedError,
// Utilities
inferShareId,
paginate,
sketch
};
Expand Down
2 changes: 1 addition & 1 deletion src/util/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { ShareDescriptor } from "../types";

function parseShareURL(url: string): ?string {
return url.split("share.goabstract.com/")[1];
return url.split(/share\.(?:go)?abstract\.com\//)[1];
}

export function inferShareId(shareDescriptor: ShareDescriptor): string {
Expand Down
5 changes: 5 additions & 0 deletions tests/util/helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ describe("helpers", () => {
url: "share.goabstract.com/share-id"
})
).toBe("share-id");
expect(
utils.inferShareId({
url: "share.abstract.com/share-id-2"
})
).toBe("share-id-2");
});

test("inferShareId throws", () => {
Expand Down

0 comments on commit 7789a92

Please sign in to comment.