Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Entry IDをURLから抽出する処理が末尾にのみマッチするよう修正 #18

Merged
merged 1 commit into from
Oct 2, 2023

Conversation

uta8a
Copy link
Contributor

@uta8a uta8a commented Oct 1, 2023

概要

EditURLからEntry IDを抽出する処理について、usernameやURLのprefixに数字が含まれる場合にEntry IDが正常に取得できなくなる場合があるので、それを修正しました。

詳細

例: 以下のケースでEntry IDが正しく抽出されません

blogsync後、ディレクトリ構造が以下のようになっている

.
└── uta8a.hatenablog.com
    └── entry
        └── 2023
            └── 10
                └── 01
                    └── 133117.md

133117.md の内容は以下のようになっている

---
Title: "2023-10-01"
EditURL: https://blog.hatena.ne.jp/uta8a/uta8a.hatenablog.com/atom/entry/820878482972134901
Draft: true
---

この時、 .github/actions/move-draft-and-update-metadata/action.yaml.github/actions/pull-draft-by-title/action.yaml の処理において、yq --front-matter=extract '.EditURL' "$file" | grep -oP '[^/]+\d' というコマンドが実行されますが、以下のようになります。

$ yq --front-matter=extract '.EditURL' "$file" | grep -oP '[^/]+\d'
uta8
uta8
820878482972134901

# 期待される動作は 820878482972134901 のみ出力

これは grep -oP '[^/]+\d'https://blog.hatena.ne.jp/uta8a/uta8a.hatenablog.com/atom/entry/820878482972134901uta8a 部分にもマッチしてしまうためです

修正案

  • $ を足して末尾のみにマッチするようにしました

@halkt
Copy link
Member

halkt commented Oct 2, 2023

@uta8a
ご迷惑おかけし申し訳ございません...

また, 修正およびご連絡ありがとうございます!
問題なさそうかと思いますので取り込ませていただきます!

@halkt halkt merged commit 9d3e238 into hatena:main Oct 2, 2023
@uta8a uta8a deleted the fix-entry-id-regex branch October 11, 2023 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants