/
common.clj
22 lines (20 loc) · 880 Bytes
/
common.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(ns super-rss.impl.common
(:require [clojure.string :as string]))
(def ^:private post-prefix #{"/post/"
"/blog/"
"/content/"
"/news/"
"/article/"})
(defn blog-url?
"Attempt to detect URL that look like a blog post with content (ie. no category, no wrongly name page that ends in the sitemap by mistake)"
[url]
(and (some #(when (string/includes? url %)
%)
post-prefix)
(not (string/includes? url "/category/"))
(not (string/includes? url "/author/"))
(not (string/includes? url "/tag/"))
(not (string/includes? url "/tags/"))
(not (string/ends-with? url "/blog/"))
(not (string/ends-with? url "/news/"))
(boolean (seq (re-find #"[a-zA-Z]+" (last (string/split url #"/")))))))