Lofter: simplify tag extraction logic

Now that we have a separate parsing class we can just use it to properly
parse tag urls as well.
This commit is contained in:
nonamethanks
2022-03-08 17:00:47 +01:00
parent 37441d6b1a
commit ff6bfff311
2 changed files with 9 additions and 13 deletions

View File

@@ -28,7 +28,7 @@
class Source::URL::Lofter < Source::URL
RESERVED_SUBDOMAINS = %w[www.lofter.com i.lofter.com]
attr_reader :username, :work_id
attr_reader :username, :work_id, :unescaped_tag
def self.match?(url)
url.domain.in?(%w[lofter.com 127.net lf127.net])
@@ -48,6 +48,10 @@ class Source::URL::Lofter < Source::URL
@username = $1
@work_id = work_id
# https://gengar563.lofter.com/tag/%E5%BA%9F%E5%BC%83%E7%9B%90%E9%85%B8%E5%A4%84%E7%90%86%E5%8E%82
in /^([a-z0-9-]+)\.lofter\.com$/, "tag", tag
@unescaped_tag = CGI.unescape(tag)
# http://gengar563.lofter.com
in /^([a-z0-9-]+)\.lofter\.com$/, *rest unless host.in?(RESERVED_SUBDOMAINS)
@username = $1