File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4,6 +4,9 @@ import { GithubPermalinkDataResponse } from "./GithubPermalinkContext";
44import { ErrorResponses } from "./GithubPermalinkContext" ;
55
66/**
7+ * This is AI generated code from GitHub Copilot.
8+ * See: https://github.com/dwjohnston/react-github-permalink/pull/79
9+ *
710 * Properly decode base64 string with UTF-8 support.
811 * GitHub API returns base64-encoded content that may contain UTF-8 characters like emojis.
912 *
@@ -16,16 +19,16 @@ import { ErrorResponses } from "./GithubPermalinkContext";
1619function decodeBase64WithUTF8 ( base64 : string ) : string {
1720 // Remove whitespace that GitHub API might include
1821 const cleanedBase64 = base64 . replace ( / \s / g, '' ) ;
19-
22+
2023 // Decode base64 to binary string (each character represents a byte)
2124 const binaryString = atob ( cleanedBase64 ) ;
22-
25+
2326 // Convert binary string to byte array
2427 const bytes = new Uint8Array ( binaryString . length ) ;
2528 for ( let i = 0 ; i < binaryString . length ; i ++ ) {
2629 bytes [ i ] = binaryString . charCodeAt ( i ) ;
2730 }
28-
31+
2932 // Decode UTF-8 bytes to string
3033 const decoder = new TextDecoder ( 'utf-8' ) ;
3134 return decoder . decode ( bytes ) ;
You can’t perform that action at this time.
0 commit comments