Skip to content
This repository was archived by the owner on Aug 30, 2021. It is now read-only.

Commit b1606c8

Browse files
Add proper link for 'Ask HN' articles
1 parent 00b23fb commit b1606c8

File tree

1 file changed

+7
-2
lines changed
  • src/clj/com/agilecreativity/hn_reader

1 file changed

+7
-2
lines changed

src/clj/com/agilecreativity/hn_reader/main.clj

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
[clojure.tools.cli :refer [parse-opts] :as cli]
55
[com.agilecreativity.hn_reader.option :refer :all :as opt]
66
[me.raynes.fs :as fs]
7-
[reaver :refer [parse extract-from extract text attr]])
7+
[reaver :refer [parse extract-from extract text attr]]
8+
[clojure.string :as str])
89
(:gen-class))
910

1011
(declare extract-data
@@ -46,7 +47,11 @@
4647
(let [head-line (:headline item)
4748
main-url (:url item)
4849
comment-url (discussion-url vote-url)]
49-
(str (hn-link-url-item main-url head-line hn-url-level) "::" comment-url))
50+
(str (hn-link-url-item
51+
(if (clojure.string/starts-with? main-url "http")
52+
main-url
53+
(str "https://news.ycombinator.com/" main-url))
54+
head-line hn-url-level) "::" comment-url))
5055

5156
;; TODO: need to find other way to get the article id (no comment link for now)!
5257
(hn-link-url-item (:url item) (:headline item) hn-url-level)))

0 commit comments

Comments
 (0)