Browse Source

fix issue with newline characters

pull/1/head
Wesley Kerfoot 5 years ago
parent
commit
829ad9ad6a
  1. 5
      src/twit2blogpkg/twitter.nim

5
src/twit2blogpkg/twitter.nim

@ -67,7 +67,8 @@ proc getThread*(tweetStart : string, user : string) : seq[string] =
proc convertWords(tweet : string) : string = proc convertWords(tweet : string) : string =
let words = tweet.split(" ") let words = tweet.split(" ")
var stripped : seq[string] var stripped : seq[string]
for word in words: for chunk in words:
for word in chunk.splitLines:
if word.len > 3 and word[0..3] == "http": if word.len > 3 and word[0..3] == "http":
let parsedUri = word.parseUri let parsedUri = word.parseUri
let scheme = parsedUri.scheme let scheme = parsedUri.scheme
@ -75,7 +76,7 @@ proc convertWords(tweet : string) : string =
let path = parsedUri.path let path = parsedUri.path
if (scheme.len > 0 and hostname.len > 0): if (scheme.len > 0 and hostname.len > 0):
stripped &= fmt"[{scheme}://{hostname}{path}]({scheme}://{hostname}{path})" stripped &= fmt"[{scheme}://{hostname}{path}]({scheme}://{hostname}{path})"
elif word[0] != '@': elif word.len > 0 and word[0] != '@':
stripped &= word stripped &= word
else: else:
continue continue

Loading…
Cancel
Save