soiz commited on
Commit
d02228f
·
verified ·
1 Parent(s): 39a5656

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +9 -15
index.html CHANGED
@@ -22,23 +22,23 @@
22
  if (!response.ok) throw new Error(`HTTPエラー: ${response.status}`);
23
  const blob = await response.blob();
24
 
25
- // 元のファイル名を取得
26
- let suggestedName = link.download || 'downloaded-file';
27
- const originalName = suggestedName; // 元の名前を保持
28
 
29
  // "."で終わる場合の修正
30
- if (suggestedName.endsWith('.')) {
31
- suggestedName = suggestedName.slice(0, -1); // 最後の "." を削除
 
32
  }
33
 
34
  // 拡張子がない場合の修正
35
- if (!/\.[a-zA-Z0-9]+$/.test(suggestedName)) {
36
- suggestedName += '.html'; // デフォルトで "html" を付加
37
  }
38
 
39
  // ファイル保存ダイアログを表示
40
  const handle = await window.showSaveFilePicker({
41
- suggestedName: suggestedName,
42
  types: [
43
  {
44
  description: 'HTML File',
@@ -57,13 +57,7 @@
57
  alert('ファイルが保存されました!');
58
  } catch (error) {
59
  console.error('エラーが発生しました:', error);
60
-
61
- // エラー詳細に元のファイル名を追加
62
- if (error.message.includes('showSaveFilePicker')) {
63
- alert(`ファイルのダウンロード中にエラーが発生しました: ${error.message}\n元のファイル名: ${originalName}`);
64
- } else {
65
- alert(`ファイルのダウンロード中にエラーが発生しました: ${error.message}`);
66
- }
67
  }
68
  });
69
  };
 
22
  if (!response.ok) throw new Error(`HTTPエラー: ${response.status}`);
23
  const blob = await response.blob();
24
 
25
+ // 元のファイル名を保持
26
+ let originalName = link.download || 'downloaded-file';
 
27
 
28
  // "."で終わる場合の修正
29
+ if (originalName.endsWith('.')) {
30
+ alert(`元のファイル名が "." で終わっています: ${originalName}`);
31
+ originalName = originalName.slice(0, -1); // 最後の "." を削除
32
  }
33
 
34
  // 拡張子がない場合の修正
35
+ if (!/\.[a-zA-Z0-9]+$/.test(originalName)) {
36
+ originalName += '.html'; // デフォルトで "html" を付加
37
  }
38
 
39
  // ファイル保存ダイアログを表示
40
  const handle = await window.showSaveFilePicker({
41
+ suggestedName: originalName,
42
  types: [
43
  {
44
  description: 'HTML File',
 
57
  alert('ファイルが保存されました!');
58
  } catch (error) {
59
  console.error('エラーが発生しました:', error);
60
+ alert(`ファイルのダウンロード中にエラーが発生しました: ${error.message}`);
 
 
 
 
 
 
61
  }
62
  });
63
  };