Skip to content

Commit

Permalink
Merge branch 'master' of github.com:three18ti/Reddit.pm
Browse files Browse the repository at this point in the history
  • Loading branch information
three18ti committed Jul 15, 2012
2 parents 675f9e5 + df76bd7 commit 60f66ec
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion source/Reddit/lib/Reddit.pm
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@ sub _parse_link {
return 't3_' . $id;
}

sub _parse_comment_id {
# ID's require a t3_ or t1_ prefix depending on whether it is a
# post or comment id respectively.
my $id = shift;
if (length($id) == 5){ $id = "t3_" . $id}
elsif (length($id) == 7){ $id = "t1_" . $id}
else { die "Invalid ID length"}
return $id;
}

# Submit link to reddit
sub submit_link {
my $self = shift;
Expand Down Expand Up @@ -217,7 +227,7 @@ sub submit_story {
sub comment {
my $self = shift;
my ($thing_id, $comment) = @_;

$thing_id = &_parse_comment_id($thing_id);
my $response = $self->post($self->comment_api,
{
thing_id => $thing_id,
Expand Down

0 comments on commit 60f66ec

Please sign in to comment.