@daisy/ace-axe-runner-electron 1.2.6-alpha.1 → 1.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/lib/init.js +131 -97
  2. package/package.json +3 -3
  3. package/src/init.js +134 -96
package/lib/init.js CHANGED
@@ -156,6 +156,7 @@ const streamProtocolHandler = async (req, callback) => {
156
156
 
157
157
  const buff = Buffer.from("<html><body><p>Internal Server Error</p><p>!_streamProtocolHandler</p></body></html>");
158
158
  headers["Content-Length"] = buff.length.toString();
159
+ headers["Content-Type"] = "text/html";
159
160
  callback({
160
161
  data: bufferToStream(buff),
161
162
  headers,
@@ -315,8 +316,9 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
315
316
  webSecurity: true,
316
317
  webviewTag: false,
317
318
  enableRemoteModule: false,
318
- partition: SESSION_PARTITION,
319
- nativeWindowOpen: false // The default of nativeWindowOpen is deprecated and will be changing from false to true in Electron 15. See https://github.com/electron/electron/issues/28511
319
+ partition: SESSION_PARTITION
320
+ // (electron) Deprecation Warning: Disabling nativeWindowOpen is deprecated. The nativeWindowOpen option will be removed in Electron 18.
321
+ // nativeWindowOpen: false, // The default of nativeWindowOpen is deprecated and will be changing from false to true in Electron 15. See https://github.com/electron/electron/issues/28511
320
322
  }
321
323
  });
322
324
 
@@ -326,7 +328,13 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
326
328
  browserWindow.webContents.session.webRequest.onBeforeRequest({
327
329
  urls: []
328
330
  }, (details, callback) => {
329
- if (details.url && /^https?:\/\//.test(details.url) && (rootUrl && !details.url.startsWith(rootUrl) || !rootUrl && !/^https?:\/\/127.0.0.1/.test(details.url))) {
331
+ if (details.url && (/^file:\/\//.test(details.url) || /^https?:\/\//.test(details.url)
332
+ // && (
333
+ // (rootUrl && !details.url.startsWith(rootUrl))
334
+ // ||
335
+ // (!rootUrl && !/^https?:\/\/127.0.0.1/.test(details.url))
336
+ // )
337
+ )) {
330
338
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} onBeforeRequest BLOCK: ${details.url} (${rootUrl})`);
331
339
 
332
340
  // causes ERR_BLOCKED_BY_CLIENT -20 did-fail-load
@@ -759,7 +767,7 @@ new Promise((resolve, reject) => {
759
767
  }
760
768
  axeRunnerInit.todo = true;
761
769
 
762
- const filePathsExpressStaticNotExist = {};
770
+ // const filePathsExpressStaticNotExist = {};
763
771
  function startAxeServer(basedir, scripts, scriptContents) {
764
772
 
765
773
  // NO_HTTP_REMOVE
@@ -830,8 +838,21 @@ function startAxeServer(basedir, scripts, scriptContents) {
830
838
  let fileSystemPath = path.join(basedir, pn);
831
839
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} filepath to read: ${fileSystemPath}`);
832
840
  if (!fs.existsSync(fileSystemPath)) {
833
- fileSystemPath = pn;
834
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} filepath to read (corrected): ${fileSystemPath}`);
841
+ // fileSystemPath = pn;
842
+ // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} filepath to read (corrected): ${fileSystemPath}`);
843
+ // if (!fs.existsSync(fileSystemPath)) {
844
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} FILE DOES NOT EXIST!! ${fileSystemPath}`);
845
+
846
+ const buff = Buffer.from(`<html><body><p>Internal Server Error</p><p>404?! ${fileSystemPath}</p></body></html>`);
847
+ headers["Content-Length"] = buff.length.toString();
848
+ headers["Content-Type"] = "text/html";
849
+ callback({
850
+ data: bufferToStream(buff),
851
+ headers,
852
+ statusCode: 404
853
+ });
854
+ return;
855
+ // }
835
856
  }
836
857
 
837
858
  // let html = fs.readFileSync(fileSystemPath, { encoding: "utf8" });
@@ -892,8 +913,21 @@ function startAxeServer(basedir, scripts, scriptContents) {
892
913
  let fileSystemPath = path.join(basedir, pn);
893
914
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} --filepath to read: ${fileSystemPath}`);
894
915
  if (!fs.existsSync(fileSystemPath)) {
895
- fileSystemPath = pn;
896
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} --filepath to read (corrected): ${fileSystemPath}`);
916
+ // fileSystemPath = pn;
917
+ // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} --filepath to read (corrected): ${fileSystemPath}`);
918
+ // if (!fs.existsSync(fileSystemPath)) {
919
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} --FILE DOES NOT EXIST!! ${fileSystemPath}`);
920
+
921
+ const buff = Buffer.from(`<html><body><p>Internal Server Error</p><p>404?! ${fileSystemPath}</p></body></html>`);
922
+ headers["Content-Length"] = buff.length.toString();
923
+ headers["Content-Type"] = "text/html";
924
+ callback({
925
+ data: bufferToStream(buff),
926
+ headers,
927
+ statusCode: 404
928
+ });
929
+ return;
930
+ // }
897
931
  }
898
932
  try {
899
933
  let mediaType = mime.lookup(fileSystemPath) || "stream/octet";
@@ -913,6 +947,7 @@ function startAxeServer(basedir, scripts, scriptContents) {
913
947
 
914
948
  const buff = Buffer.from(`<html><body><p>Internal Server Error</p><p>fsErr: ${fsErr}</p></body></html>`);
915
949
  headers["Content-Length"] = buff.length.toString();
950
+ headers["Content-Type"] = "text/html";
916
951
  callback({
917
952
  data: bufferToStream(buff),
918
953
  headers,
@@ -920,95 +955,94 @@ function startAxeServer(basedir, scripts, scriptContents) {
920
955
  });
921
956
  }
922
957
 
923
- if (isDev) {
924
- // handle WebInspector JS maps etc.
925
-
926
- // const url = new URL(`https://fake.org${req.url}`);
927
- // const pathname = url.pathname;
928
- const pathname = decodeURI(u.pathname);
929
-
930
- const filePath = path.join(basedir, pathname);
931
- if (filePathsExpressStaticNotExist[filePath]) {
932
-
933
- const buff = Buffer.from(filePathsExpressStaticNotExist[filePath]);
934
- headers["Content-Length"] = buff.length.toString();
935
- headers["Content-Type"] = "plain/text";
936
- callback({
937
- data: bufferToStream(buff),
938
- headers,
939
- statusCode: 404
940
- });
941
- return;
942
- }
943
- fsOriginal.exists(filePath, exists => {
944
- if (exists) {
945
- fsOriginal.readFile(filePath, undefined, (err, data) => {
946
- if (err) {
947
- if (LOG_DEBUG) {
948
- console.log(`${ACE_LOG_PREFIX} HTTP FAIL fsOriginal.exists && ERR ${basedir} + ${req.url} => ${filePath}`, err);
949
- }
950
- filePathsExpressStaticNotExist[filePath] = err.toString();
951
- const buff = Buffer.from(filePathsExpressStaticNotExist[filePath]);
952
- headers["Content-Length"] = buff.length.toString();
953
- headers["Content-Type"] = "plain/text";
954
- callback({
955
- data: bufferToStream(buff),
956
- headers,
957
- statusCode: 404
958
- });
959
- } else {
960
- // if (LOG_DEBUG) {
961
- // console.log(`${ACE_LOG_PREFIX} HTTP OK fsOriginal.exists ${basedir} + ${req.url} => ${filePath}`);
962
- // }
963
- callback({
964
- data: null,
965
- headers,
966
- statusCode: 500
967
- });
968
- }
969
- });
970
- } else {
971
- fs.exists(filePath, exists => {
972
- if (exists) {
973
- fs.readFile(filePath, undefined, (err, data) => {
974
- if (err) {
975
- if (LOG_DEBUG) {
976
- console.log(`${ACE_LOG_PREFIX} HTTP FAIL !fsOriginal.exists && fs.exists && ERR ${basedir} + ${req.url} => ${filePath}`, err);
977
- }
978
- filePathsExpressStaticNotExist[filePath] = err.toString();
979
- const buff = Buffer.from(filePathsExpressStaticNotExist[filePath]);
980
- headers["Content-Length"] = buff.length.toString();
981
- headers["Content-Type"] = "plain/text";
982
- callback({
983
- data: bufferToStream(buff),
984
- headers,
985
- statusCode: 404
986
- });
987
- } else {
988
- if (LOG_DEBUG) {
989
- console.log(`${ACE_LOG_PREFIX} HTTP OK !fsOriginal.exists && fs.exists ${basedir} + ${req.url} => ${filePath}`);
990
- }
991
- callback({
992
- data: null,
993
- headers,
994
- statusCode: 500
995
- });
996
- }
997
- });
998
- } else {
999
- if (LOG_DEBUG) {
1000
- console.log(`${ACE_LOG_PREFIX} HTTP FAIL !fsOriginal.exists && !fs.exists ${basedir} + ${req.url} => ${filePath}`);
1001
- }
1002
- callback({
1003
- data: null,
1004
- headers,
1005
- statusCode: 404
1006
- });
1007
- }
1008
- });
1009
- }
1010
- });
1011
- }
958
+ // if (isDev) { // handle WebInspector JS maps etc.
959
+
960
+ // // const url = new URL(`https://fake.org${req.url}`);
961
+ // // const pathname = url.pathname;
962
+ // const pathname = decodeURI(u.pathname);
963
+
964
+ // const filePath = path.join(basedir, pathname);
965
+ // if (filePathsExpressStaticNotExist[filePath]) {
966
+
967
+ // const buff = Buffer.from(filePathsExpressStaticNotExist[filePath]);
968
+ // headers["Content-Length"] = buff.length.toString();
969
+ // headers["Content-Type"] = "plain/text";
970
+ // callback({
971
+ // data: bufferToStream(buff),
972
+ // headers,
973
+ // statusCode: 404,
974
+ // });
975
+ // return;
976
+ // }
977
+ // fsOriginal.exists(filePath, (exists) => {
978
+ // if (exists) {
979
+ // fsOriginal.readFile(filePath, undefined, (err, data) => {
980
+ // if (err) {
981
+ // if (LOG_DEBUG) {
982
+ // console.log(`${ACE_LOG_PREFIX} HTTP FAIL fsOriginal.exists && ERR ${basedir} + ${req.url} => ${filePath}`, err);
983
+ // }
984
+ // filePathsExpressStaticNotExist[filePath] = err.toString();
985
+ // const buff = Buffer.from(filePathsExpressStaticNotExist[filePath]);
986
+ // headers["Content-Length"] = buff.length.toString();
987
+ // headers["Content-Type"] = "plain/text";
988
+ // callback({
989
+ // data: bufferToStream(buff),
990
+ // headers,
991
+ // statusCode: 404,
992
+ // });
993
+ // } else {
994
+ // // if (LOG_DEBUG) {
995
+ // // console.log(`${ACE_LOG_PREFIX} HTTP OK fsOriginal.exists ${basedir} + ${req.url} => ${filePath}`);
996
+ // // }
997
+ // callback({
998
+ // data: null,
999
+ // headers,
1000
+ // statusCode: 500,
1001
+ // });
1002
+ // }
1003
+ // });
1004
+ // } else {
1005
+ // fs.exists(filePath, (exists) => {
1006
+ // if (exists) {
1007
+ // fs.readFile(filePath, undefined, (err, data) => {
1008
+ // if (err) {
1009
+ // if (LOG_DEBUG) {
1010
+ // console.log(`${ACE_LOG_PREFIX} HTTP FAIL !fsOriginal.exists && fs.exists && ERR ${basedir} + ${req.url} => ${filePath}`, err);
1011
+ // }
1012
+ // filePathsExpressStaticNotExist[filePath] = err.toString();
1013
+ // const buff = Buffer.from(filePathsExpressStaticNotExist[filePath]);
1014
+ // headers["Content-Length"] = buff.length.toString();
1015
+ // headers["Content-Type"] = "plain/text";
1016
+ // callback({
1017
+ // data: bufferToStream(buff),
1018
+ // headers,
1019
+ // statusCode: 404,
1020
+ // });
1021
+ // } else {
1022
+ // if (LOG_DEBUG) {
1023
+ // console.log(`${ACE_LOG_PREFIX} HTTP OK !fsOriginal.exists && fs.exists ${basedir} + ${req.url} => ${filePath}`);
1024
+ // }
1025
+ // callback({
1026
+ // data: null,
1027
+ // headers,
1028
+ // statusCode: 500,
1029
+ // });
1030
+ // }
1031
+ // });
1032
+ // } else {
1033
+ // if (LOG_DEBUG) {
1034
+ // console.log(`${ACE_LOG_PREFIX} HTTP FAIL !fsOriginal.exists && !fs.exists ${basedir} + ${req.url} => ${filePath}`);
1035
+ // }
1036
+ // callback({
1037
+ // data: null,
1038
+ // headers,
1039
+ // statusCode: 404,
1040
+ // });
1041
+ // }
1042
+ // });
1043
+ // }
1044
+ // });
1045
+ // }
1012
1046
  };
1013
1047
 
1014
1048
  // NO_HTTP_REMOVE
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@daisy/ace-axe-runner-electron",
3
- "version": "1.2.6-alpha.1",
3
+ "version": "1.2.6",
4
4
  "engines": {
5
5
  "node": ">=12.0.0",
6
6
  "yarn": "^1.22.0",
@@ -23,12 +23,12 @@
23
23
  "license": "MIT",
24
24
  "main": "lib/index.js",
25
25
  "dependencies": {
26
- "@daisy/ace-cli-shared": "^1.2.6-alpha.1",
26
+ "@daisy/ace-cli-shared": "^1.2.6",
27
27
  "mime-types": "^2.1.34",
28
28
  "uuid": "^8.3.2"
29
29
  },
30
30
  "devDependencies": {
31
- "electron": "^16.0.7",
31
+ "electron": "^17.0.0",
32
32
  "json": "^11.0.0",
33
33
  "json-diff": "^0.7.1"
34
34
  },
package/src/init.js CHANGED
@@ -160,6 +160,7 @@ const streamProtocolHandler = async (
160
160
 
161
161
  const buff = Buffer.from("<html><body><p>Internal Server Error</p><p>!_streamProtocolHandler</p></body></html>");
162
162
  headers["Content-Length"] = buff.length.toString();
163
+ headers["Content-Type"] = "text/html";
163
164
  callback({
164
165
  data: bufferToStream(buff),
165
166
  headers,
@@ -322,7 +323,8 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
322
323
  webviewTag: false,
323
324
  enableRemoteModule: false,
324
325
  partition: SESSION_PARTITION,
325
- nativeWindowOpen: false, // The default of nativeWindowOpen is deprecated and will be changing from false to true in Electron 15. See https://github.com/electron/electron/issues/28511
326
+ // (electron) Deprecation Warning: Disabling nativeWindowOpen is deprecated. The nativeWindowOpen option will be removed in Electron 18.
327
+ // nativeWindowOpen: false, // The default of nativeWindowOpen is deprecated and will be changing from false to true in Electron 15. See https://github.com/electron/electron/issues/28511
326
328
  },
327
329
  });
328
330
 
@@ -333,8 +335,17 @@ function axeRunnerInit(eventEmmitter, CONCURRENT_INSTANCES) {
333
335
  urls: [],
334
336
  }, (details, callback) => {
335
337
  if (details.url
336
- && /^https?:\/\//.test(details.url)
337
- && ((rootUrl && !details.url.startsWith(rootUrl)) || (!rootUrl && !/^https?:\/\/127.0.0.1/.test(details.url)))
338
+ &&
339
+ (
340
+ /^file:\/\//.test(details.url)
341
+ ||
342
+ /^https?:\/\//.test(details.url)
343
+ // && (
344
+ // (rootUrl && !details.url.startsWith(rootUrl))
345
+ // ||
346
+ // (!rootUrl && !/^https?:\/\/127.0.0.1/.test(details.url))
347
+ // )
348
+ )
338
349
  ) {
339
350
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} onBeforeRequest BLOCK: ${details.url} (${rootUrl})`);
340
351
 
@@ -780,7 +791,7 @@ new Promise((resolve, reject) => {
780
791
  }
781
792
  axeRunnerInit.todo = true;
782
793
 
783
- const filePathsExpressStaticNotExist = {};
794
+ // const filePathsExpressStaticNotExist = {};
784
795
  function startAxeServer(basedir, scripts, scriptContents) {
785
796
 
786
797
  // NO_HTTP_REMOVE
@@ -854,8 +865,21 @@ function startAxeServer(basedir, scripts, scriptContents) {
854
865
  let fileSystemPath = path.join(basedir, pn);
855
866
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} filepath to read: ${fileSystemPath}`);
856
867
  if (!fs.existsSync(fileSystemPath)) {
857
- fileSystemPath = pn;
858
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} filepath to read (corrected): ${fileSystemPath}`);
868
+ // fileSystemPath = pn;
869
+ // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} filepath to read (corrected): ${fileSystemPath}`);
870
+ // if (!fs.existsSync(fileSystemPath)) {
871
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} FILE DOES NOT EXIST!! ${fileSystemPath}`);
872
+
873
+ const buff = Buffer.from(`<html><body><p>Internal Server Error</p><p>404?! ${fileSystemPath}</p></body></html>`);
874
+ headers["Content-Length"] = buff.length.toString();
875
+ headers["Content-Type"] = "text/html";
876
+ callback({
877
+ data: bufferToStream(buff),
878
+ headers,
879
+ statusCode: 404,
880
+ });
881
+ return;
882
+ // }
859
883
  }
860
884
 
861
885
  // let html = fs.readFileSync(fileSystemPath, { encoding: "utf8" });
@@ -916,8 +940,21 @@ function startAxeServer(basedir, scripts, scriptContents) {
916
940
  let fileSystemPath = path.join(basedir, pn);
917
941
  if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} --filepath to read: ${fileSystemPath}`);
918
942
  if (!fs.existsSync(fileSystemPath)) {
919
- fileSystemPath = pn;
920
- if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} --filepath to read (corrected): ${fileSystemPath}`);
943
+ // fileSystemPath = pn;
944
+ // if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} --filepath to read (corrected): ${fileSystemPath}`);
945
+ // if (!fs.existsSync(fileSystemPath)) {
946
+ if (LOG_DEBUG) console.log(`${ACE_LOG_PREFIX} --FILE DOES NOT EXIST!! ${fileSystemPath}`);
947
+
948
+ const buff = Buffer.from(`<html><body><p>Internal Server Error</p><p>404?! ${fileSystemPath}</p></body></html>`);
949
+ headers["Content-Length"] = buff.length.toString();
950
+ headers["Content-Type"] = "text/html";
951
+ callback({
952
+ data: bufferToStream(buff),
953
+ headers,
954
+ statusCode: 404,
955
+ });
956
+ return;
957
+ // }
921
958
  }
922
959
  try {
923
960
  let mediaType = mime.lookup(fileSystemPath) || "stream/octet";
@@ -937,6 +974,7 @@ function startAxeServer(basedir, scripts, scriptContents) {
937
974
 
938
975
  const buff = Buffer.from(`<html><body><p>Internal Server Error</p><p>fsErr: ${fsErr}</p></body></html>`);
939
976
  headers["Content-Length"] = buff.length.toString();
977
+ headers["Content-Type"] = "text/html";
940
978
  callback({
941
979
  data: bufferToStream(buff),
942
980
  headers,
@@ -944,94 +982,94 @@ function startAxeServer(basedir, scripts, scriptContents) {
944
982
  });
945
983
  }
946
984
 
947
- if (isDev) { // handle WebInspector JS maps etc.
948
-
949
- // const url = new URL(`https://fake.org${req.url}`);
950
- // const pathname = url.pathname;
951
- const pathname = decodeURI(u.pathname);
952
-
953
- const filePath = path.join(basedir, pathname);
954
- if (filePathsExpressStaticNotExist[filePath]) {
955
-
956
- const buff = Buffer.from(filePathsExpressStaticNotExist[filePath]);
957
- headers["Content-Length"] = buff.length.toString();
958
- headers["Content-Type"] = "plain/text";
959
- callback({
960
- data: bufferToStream(buff),
961
- headers,
962
- statusCode: 404,
963
- });
964
- return;
965
- }
966
- fsOriginal.exists(filePath, (exists) => {
967
- if (exists) {
968
- fsOriginal.readFile(filePath, undefined, (err, data) => {
969
- if (err) {
970
- if (LOG_DEBUG) {
971
- console.log(`${ACE_LOG_PREFIX} HTTP FAIL fsOriginal.exists && ERR ${basedir} + ${req.url} => ${filePath}`, err);
972
- }
973
- filePathsExpressStaticNotExist[filePath] = err.toString();
974
- const buff = Buffer.from(filePathsExpressStaticNotExist[filePath]);
975
- headers["Content-Length"] = buff.length.toString();
976
- headers["Content-Type"] = "plain/text";
977
- callback({
978
- data: bufferToStream(buff),
979
- headers,
980
- statusCode: 404,
981
- });
982
- } else {
983
- // if (LOG_DEBUG) {
984
- // console.log(`${ACE_LOG_PREFIX} HTTP OK fsOriginal.exists ${basedir} + ${req.url} => ${filePath}`);
985
- // }
986
- callback({
987
- data: null,
988
- headers,
989
- statusCode: 500,
990
- });
991
- }
992
- });
993
- } else {
994
- fs.exists(filePath, (exists) => {
995
- if (exists) {
996
- fs.readFile(filePath, undefined, (err, data) => {
997
- if (err) {
998
- if (LOG_DEBUG) {
999
- console.log(`${ACE_LOG_PREFIX} HTTP FAIL !fsOriginal.exists && fs.exists && ERR ${basedir} + ${req.url} => ${filePath}`, err);
1000
- }
1001
- filePathsExpressStaticNotExist[filePath] = err.toString();
1002
- const buff = Buffer.from(filePathsExpressStaticNotExist[filePath]);
1003
- headers["Content-Length"] = buff.length.toString();
1004
- headers["Content-Type"] = "plain/text";
1005
- callback({
1006
- data: bufferToStream(buff),
1007
- headers,
1008
- statusCode: 404,
1009
- });
1010
- } else {
1011
- if (LOG_DEBUG) {
1012
- console.log(`${ACE_LOG_PREFIX} HTTP OK !fsOriginal.exists && fs.exists ${basedir} + ${req.url} => ${filePath}`);
1013
- }
1014
- callback({
1015
- data: null,
1016
- headers,
1017
- statusCode: 500,
1018
- });
1019
- }
1020
- });
1021
- } else {
1022
- if (LOG_DEBUG) {
1023
- console.log(`${ACE_LOG_PREFIX} HTTP FAIL !fsOriginal.exists && !fs.exists ${basedir} + ${req.url} => ${filePath}`);
1024
- }
1025
- callback({
1026
- data: null,
1027
- headers,
1028
- statusCode: 404,
1029
- });
1030
- }
1031
- });
1032
- }
1033
- });
1034
- }
985
+ // if (isDev) { // handle WebInspector JS maps etc.
986
+
987
+ // // const url = new URL(`https://fake.org${req.url}`);
988
+ // // const pathname = url.pathname;
989
+ // const pathname = decodeURI(u.pathname);
990
+
991
+ // const filePath = path.join(basedir, pathname);
992
+ // if (filePathsExpressStaticNotExist[filePath]) {
993
+
994
+ // const buff = Buffer.from(filePathsExpressStaticNotExist[filePath]);
995
+ // headers["Content-Length"] = buff.length.toString();
996
+ // headers["Content-Type"] = "plain/text";
997
+ // callback({
998
+ // data: bufferToStream(buff),
999
+ // headers,
1000
+ // statusCode: 404,
1001
+ // });
1002
+ // return;
1003
+ // }
1004
+ // fsOriginal.exists(filePath, (exists) => {
1005
+ // if (exists) {
1006
+ // fsOriginal.readFile(filePath, undefined, (err, data) => {
1007
+ // if (err) {
1008
+ // if (LOG_DEBUG) {
1009
+ // console.log(`${ACE_LOG_PREFIX} HTTP FAIL fsOriginal.exists && ERR ${basedir} + ${req.url} => ${filePath}`, err);
1010
+ // }
1011
+ // filePathsExpressStaticNotExist[filePath] = err.toString();
1012
+ // const buff = Buffer.from(filePathsExpressStaticNotExist[filePath]);
1013
+ // headers["Content-Length"] = buff.length.toString();
1014
+ // headers["Content-Type"] = "plain/text";
1015
+ // callback({
1016
+ // data: bufferToStream(buff),
1017
+ // headers,
1018
+ // statusCode: 404,
1019
+ // });
1020
+ // } else {
1021
+ // // if (LOG_DEBUG) {
1022
+ // // console.log(`${ACE_LOG_PREFIX} HTTP OK fsOriginal.exists ${basedir} + ${req.url} => ${filePath}`);
1023
+ // // }
1024
+ // callback({
1025
+ // data: null,
1026
+ // headers,
1027
+ // statusCode: 500,
1028
+ // });
1029
+ // }
1030
+ // });
1031
+ // } else {
1032
+ // fs.exists(filePath, (exists) => {
1033
+ // if (exists) {
1034
+ // fs.readFile(filePath, undefined, (err, data) => {
1035
+ // if (err) {
1036
+ // if (LOG_DEBUG) {
1037
+ // console.log(`${ACE_LOG_PREFIX} HTTP FAIL !fsOriginal.exists && fs.exists && ERR ${basedir} + ${req.url} => ${filePath}`, err);
1038
+ // }
1039
+ // filePathsExpressStaticNotExist[filePath] = err.toString();
1040
+ // const buff = Buffer.from(filePathsExpressStaticNotExist[filePath]);
1041
+ // headers["Content-Length"] = buff.length.toString();
1042
+ // headers["Content-Type"] = "plain/text";
1043
+ // callback({
1044
+ // data: bufferToStream(buff),
1045
+ // headers,
1046
+ // statusCode: 404,
1047
+ // });
1048
+ // } else {
1049
+ // if (LOG_DEBUG) {
1050
+ // console.log(`${ACE_LOG_PREFIX} HTTP OK !fsOriginal.exists && fs.exists ${basedir} + ${req.url} => ${filePath}`);
1051
+ // }
1052
+ // callback({
1053
+ // data: null,
1054
+ // headers,
1055
+ // statusCode: 500,
1056
+ // });
1057
+ // }
1058
+ // });
1059
+ // } else {
1060
+ // if (LOG_DEBUG) {
1061
+ // console.log(`${ACE_LOG_PREFIX} HTTP FAIL !fsOriginal.exists && !fs.exists ${basedir} + ${req.url} => ${filePath}`);
1062
+ // }
1063
+ // callback({
1064
+ // data: null,
1065
+ // headers,
1066
+ // statusCode: 404,
1067
+ // });
1068
+ // }
1069
+ // });
1070
+ // }
1071
+ // });
1072
+ // }
1035
1073
  };
1036
1074
 
1037
1075
  // NO_HTTP_REMOVE