Skip to content

Clipboard API 非対応環境での copyCode() 可用性チェック追加 #307

@coderabbitai

Description

@coderabbitai

概要

Sherlock_and_Divisors.html の copyCode() 関数で、Clipboard API が利用できない環境(非セキュアコンテキストや未対応ブラウザなど)において、navigator.clipboardundefined となり同期エラーが発生する問題があります。

対象ファイル

Mathematics/Fundamentals/HackerRank/Claude/Easy/Sherlock and Divisors/Sherlock_and_Divisors.html
Lines: 471-493

問題点

  • navigator.clipboard にアクセスする際、当該 API が無い環境では同期エラーが発生
  • Promise の .catch() に到達しないため、ユーザーへのフィードバックが返らない
  • writeText 呼び出し前の可用性チェックが不足

対応内容

navigator.clipboard および window.isSecureContext の存在チェックを追加し、利用不可時には明示的にエラーハンドリングを行うよう改善する必要があります。

関連情報

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions