Skip to content

Commit

Permalink
should have better tests for DocUrl but this prevents errors for non-…
Browse files Browse the repository at this point in the history
…string falsy inputs
  • Loading branch information
pvh committed Oct 30, 2023
1 parent 254bad1 commit 7b20344
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/automerge-repo/src/DocUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ export const stringifyAutomergeUrl = ({
* @param str: URL candidate
* @returns boolean
*/
export const isValidAutomergeUrl = (str: string): str is AutomergeUrl => {
if (!str.startsWith(urlPrefix)) return false
export const isValidAutomergeUrl = (
str: string | undefined | null
): str is AutomergeUrl => {
if (!str || !str.startsWith(urlPrefix)) return false

const { binaryDocumentId: documentId } = parts(str)
return documentId ? true : false
Expand Down

0 comments on commit 7b20344

Please sign in to comment.