@@ -45,6 +45,43 @@ const Builder = () => {
45
45
< Script id = "monaco-editor" >
46
46
{ `
47
47
var require = { paths: { 'vs': 'third-party/monaco-editor/package/min/vs' } };
48
+
49
+ const originalFetch = window.fetch;
50
+ window.fetch = function(input, init) {
51
+ let url;
52
+ if (typeof input === 'string') {
53
+ url = input;
54
+ } else if (input instanceof Request) {
55
+ url = input.url;
56
+ } else {
57
+ return originalFetch(input, init);
58
+ }
59
+
60
+ try {
61
+ const parsedUrl = new URL(url);
62
+ const path = parsedUrl.pathname;
63
+
64
+ if (path.startsWith('/vs')) {
65
+ const newPath = \`/third-party/monaco-editor/${ monaco_version } /package/min\${path}\`;
66
+
67
+ return originalFetch(newPath, init);
68
+ }
69
+ } catch (e) {
70
+ if (url.startsWith('vs')) {
71
+ const newPath = \`/third-party/monaco-editor/${ monaco_version } /package/min/\${url}\`;
72
+
73
+ return originalFetch(newPath, init);
74
+ } else if (url.startsWith('/vs')) {
75
+ const newPath = \`/third-party/monaco-editor/${ monaco_version } /package/min\${url}\`;
76
+
77
+ return originalFetch(newPath, init);
78
+ } else {
79
+ return originalFetch(input, init);
80
+ }
81
+ }
82
+
83
+ return originalFetch(input, init);
84
+ };
48
85
` }
49
86
</ Script >
50
87
< script src = { `/third-party/monaco-editor/${ monaco_version } /package/min/vs/loader.js` } > </ script >
0 commit comments