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

記事内の URL のリンク切れを検出するスクリプトの作成 #1

Open
noraworld opened this issue Mar 3, 2021 · 0 comments

Comments

@noraworld
Copy link
Owner

記事内の URL を正規表現かなにかでマッチさせて、その URL のヘッダ情報のみを取得し、404 Not Found を検出する。

ヘッダ情報のみを取得する理由は、単純に本文は要らないのと、本文も取得しようとするとリクエストに時間がかかるから。

スクリプトは bin ディレクトリでも作ってそこに置いておくのが良いだろう。

ざっくりとした仕様は以下の通り。コマンド名は適当。

# 無引数の場合は全記事の内の全 URL をチェックする
$ bin/check-broken-link

# パスを引数として指定したらその記事内の URL のみをチェックする
$ bin/check-broken-link articles/foo-bar-baz

# 全 URL と HTTP ステータスコードを表示する
# 200 OK などの URL も含めて、すべて表示する
# これは記事内の URL を正規表現等で正しく抽出できるかの、いわばデバッグ用のオプション
$ bin/check-broken-link --verbose
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

No branches or pull requests

1 participant