Skip to content

Missing null check in pipe: Wrong parameter in TimeagoPipe #45

@BojanKogoj

Description

@BojanKogoj

Current behavior

Pipe crashes when value is missing

ERROR SyntaxError: Wrong parameter in TimeagoPipe. Expected a valid date, received: null

This will happen while you wait for content to load

{{ item?.createdAt | timeago }}

This will most likely happen during testing, when you don't mock whole object.

Expected behavior

Display nothing

How do you think that we should fix this?

Add null check

Minimal reproduction of the problem with instructions

{{ '' | timeago}}
{{ undefined | timeago}}
{{ null | timeago}}

Environment


ngx-timeago version: ^1.0.4
Angular version: 10.0.12

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @BojanKogoj

        Issue actions

          Missing null check in pipe: Wrong parameter in TimeagoPipe · Issue #45 · ihym/ngx-timeago