Hm, am I not thinking straight or wouldn't something simpler like

```ruby
  LINK_PATTERN = %r{https?://\S+}
...

  def add_post_link(post, post_text, maxchars)
   ...

    truncated_text = truncate post_text, length: maxchars - SHORTENED_URL_LENGTH + 1
    truncated_text = restore_truncated_url truncated_text, post_text, maxchars

    "#{truncated_text} #{post_url}"
  end

  def restore_truncated_url truncated_text, post_text, maxchars
    return truncated_text if truncated_text !~ /#{LINK_PATTERN}\Z/

    url = post_text.match(LINK_PATTERN, truncated_text.rindex('http'))[0]
    truncated_text = truncate(
      post_text,
      length: max_characters - SHORTENED_URL_LENGTH + 2,
      separator: ' ',
      omission: ''
    )

    "#{truncated_text} #{url} ..."
  end
...
```

work too? What edge case did I forget?