@putkoff/abstract-utilities 0.1.242 → 0.1.243
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.
- package/dist/cjs/index.js +11 -511
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +13 -514
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var react = require('react');
|
|
4
4
|
var path = require('path');
|
|
5
|
+
var path$2 = require('path-browserify');
|
|
5
6
|
var fs = require('node:fs');
|
|
6
7
|
var fsp = require('node:fs/promises');
|
|
7
8
|
var path$1 = require('node:path');
|
|
@@ -25,6 +26,7 @@ function _interopNamespaceDefault(e) {
|
|
|
25
26
|
return Object.freeze(n);
|
|
26
27
|
}
|
|
27
28
|
|
|
29
|
+
var path__namespace$1 = /*#__PURE__*/_interopNamespaceDefault(path$2);
|
|
28
30
|
var fs__namespace = /*#__PURE__*/_interopNamespaceDefault(fs);
|
|
29
31
|
var fsp__namespace = /*#__PURE__*/_interopNamespaceDefault(fsp);
|
|
30
32
|
var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path$1);
|
|
@@ -668,508 +670,6 @@ function url_to_path(urlStr, all_paths) {
|
|
|
668
670
|
return null;
|
|
669
671
|
}
|
|
670
672
|
|
|
671
|
-
function assertPath(path) {
|
|
672
|
-
if (typeof path !== 'string') {
|
|
673
|
-
throw new TypeError('Path must be a string. Received ' + JSON.stringify(path));
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
// Resolves . and .. elements in a path with directory names
|
|
678
|
-
function normalizeStringPosix(path, allowAboveRoot) {
|
|
679
|
-
var res = '';
|
|
680
|
-
var lastSegmentLength = 0;
|
|
681
|
-
var lastSlash = -1;
|
|
682
|
-
var dots = 0;
|
|
683
|
-
var code;
|
|
684
|
-
for (var i = 0; i <= path.length; ++i) {
|
|
685
|
-
if (i < path.length)
|
|
686
|
-
code = path.charCodeAt(i);
|
|
687
|
-
else if (code === 47 /*/*/)
|
|
688
|
-
break;
|
|
689
|
-
else
|
|
690
|
-
code = 47 /*/*/;
|
|
691
|
-
if (code === 47 /*/*/) {
|
|
692
|
-
if (lastSlash === i - 1 || dots === 1) ; else if (lastSlash !== i - 1 && dots === 2) {
|
|
693
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) {
|
|
694
|
-
if (res.length > 2) {
|
|
695
|
-
var lastSlashIndex = res.lastIndexOf('/');
|
|
696
|
-
if (lastSlashIndex !== res.length - 1) {
|
|
697
|
-
if (lastSlashIndex === -1) {
|
|
698
|
-
res = '';
|
|
699
|
-
lastSegmentLength = 0;
|
|
700
|
-
} else {
|
|
701
|
-
res = res.slice(0, lastSlashIndex);
|
|
702
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
|
|
703
|
-
}
|
|
704
|
-
lastSlash = i;
|
|
705
|
-
dots = 0;
|
|
706
|
-
continue;
|
|
707
|
-
}
|
|
708
|
-
} else if (res.length === 2 || res.length === 1) {
|
|
709
|
-
res = '';
|
|
710
|
-
lastSegmentLength = 0;
|
|
711
|
-
lastSlash = i;
|
|
712
|
-
dots = 0;
|
|
713
|
-
continue;
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
if (allowAboveRoot) {
|
|
717
|
-
if (res.length > 0)
|
|
718
|
-
res += '/..';
|
|
719
|
-
else
|
|
720
|
-
res = '..';
|
|
721
|
-
lastSegmentLength = 2;
|
|
722
|
-
}
|
|
723
|
-
} else {
|
|
724
|
-
if (res.length > 0)
|
|
725
|
-
res += '/' + path.slice(lastSlash + 1, i);
|
|
726
|
-
else
|
|
727
|
-
res = path.slice(lastSlash + 1, i);
|
|
728
|
-
lastSegmentLength = i - lastSlash - 1;
|
|
729
|
-
}
|
|
730
|
-
lastSlash = i;
|
|
731
|
-
dots = 0;
|
|
732
|
-
} else if (code === 46 /*.*/ && dots !== -1) {
|
|
733
|
-
++dots;
|
|
734
|
-
} else {
|
|
735
|
-
dots = -1;
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
return res;
|
|
739
|
-
}
|
|
740
|
-
|
|
741
|
-
function _format(sep, pathObject) {
|
|
742
|
-
var dir = pathObject.dir || pathObject.root;
|
|
743
|
-
var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || '');
|
|
744
|
-
if (!dir) {
|
|
745
|
-
return base;
|
|
746
|
-
}
|
|
747
|
-
if (dir === pathObject.root) {
|
|
748
|
-
return dir + base;
|
|
749
|
-
}
|
|
750
|
-
return dir + sep + base;
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
var posix = {
|
|
754
|
-
// path.resolve([from ...], to)
|
|
755
|
-
resolve: function resolve() {
|
|
756
|
-
var resolvedPath = '';
|
|
757
|
-
var resolvedAbsolute = false;
|
|
758
|
-
var cwd;
|
|
759
|
-
|
|
760
|
-
for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
761
|
-
var path;
|
|
762
|
-
if (i >= 0)
|
|
763
|
-
path = arguments[i];
|
|
764
|
-
else {
|
|
765
|
-
if (cwd === undefined)
|
|
766
|
-
cwd = process.cwd();
|
|
767
|
-
path = cwd;
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
assertPath(path);
|
|
771
|
-
|
|
772
|
-
// Skip empty entries
|
|
773
|
-
if (path.length === 0) {
|
|
774
|
-
continue;
|
|
775
|
-
}
|
|
776
|
-
|
|
777
|
-
resolvedPath = path + '/' + resolvedPath;
|
|
778
|
-
resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/;
|
|
779
|
-
}
|
|
780
|
-
|
|
781
|
-
// At this point the path should be resolved to a full absolute path, but
|
|
782
|
-
// handle relative paths to be safe (might happen when process.cwd() fails)
|
|
783
|
-
|
|
784
|
-
// Normalize the path
|
|
785
|
-
resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute);
|
|
786
|
-
|
|
787
|
-
if (resolvedAbsolute) {
|
|
788
|
-
if (resolvedPath.length > 0)
|
|
789
|
-
return '/' + resolvedPath;
|
|
790
|
-
else
|
|
791
|
-
return '/';
|
|
792
|
-
} else if (resolvedPath.length > 0) {
|
|
793
|
-
return resolvedPath;
|
|
794
|
-
} else {
|
|
795
|
-
return '.';
|
|
796
|
-
}
|
|
797
|
-
},
|
|
798
|
-
|
|
799
|
-
normalize: function normalize(path) {
|
|
800
|
-
assertPath(path);
|
|
801
|
-
|
|
802
|
-
if (path.length === 0) return '.';
|
|
803
|
-
|
|
804
|
-
var isAbsolute = path.charCodeAt(0) === 47 /*/*/;
|
|
805
|
-
var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/;
|
|
806
|
-
|
|
807
|
-
// Normalize the path
|
|
808
|
-
path = normalizeStringPosix(path, !isAbsolute);
|
|
809
|
-
|
|
810
|
-
if (path.length === 0 && !isAbsolute) path = '.';
|
|
811
|
-
if (path.length > 0 && trailingSeparator) path += '/';
|
|
812
|
-
|
|
813
|
-
if (isAbsolute) return '/' + path;
|
|
814
|
-
return path;
|
|
815
|
-
},
|
|
816
|
-
|
|
817
|
-
isAbsolute: function isAbsolute(path) {
|
|
818
|
-
assertPath(path);
|
|
819
|
-
return path.length > 0 && path.charCodeAt(0) === 47 /*/*/;
|
|
820
|
-
},
|
|
821
|
-
|
|
822
|
-
join: function join() {
|
|
823
|
-
if (arguments.length === 0)
|
|
824
|
-
return '.';
|
|
825
|
-
var joined;
|
|
826
|
-
for (var i = 0; i < arguments.length; ++i) {
|
|
827
|
-
var arg = arguments[i];
|
|
828
|
-
assertPath(arg);
|
|
829
|
-
if (arg.length > 0) {
|
|
830
|
-
if (joined === undefined)
|
|
831
|
-
joined = arg;
|
|
832
|
-
else
|
|
833
|
-
joined += '/' + arg;
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
if (joined === undefined)
|
|
837
|
-
return '.';
|
|
838
|
-
return posix.normalize(joined);
|
|
839
|
-
},
|
|
840
|
-
|
|
841
|
-
relative: function relative(from, to) {
|
|
842
|
-
assertPath(from);
|
|
843
|
-
assertPath(to);
|
|
844
|
-
|
|
845
|
-
if (from === to) return '';
|
|
846
|
-
|
|
847
|
-
from = posix.resolve(from);
|
|
848
|
-
to = posix.resolve(to);
|
|
849
|
-
|
|
850
|
-
if (from === to) return '';
|
|
851
|
-
|
|
852
|
-
// Trim any leading backslashes
|
|
853
|
-
var fromStart = 1;
|
|
854
|
-
for (; fromStart < from.length; ++fromStart) {
|
|
855
|
-
if (from.charCodeAt(fromStart) !== 47 /*/*/)
|
|
856
|
-
break;
|
|
857
|
-
}
|
|
858
|
-
var fromEnd = from.length;
|
|
859
|
-
var fromLen = fromEnd - fromStart;
|
|
860
|
-
|
|
861
|
-
// Trim any leading backslashes
|
|
862
|
-
var toStart = 1;
|
|
863
|
-
for (; toStart < to.length; ++toStart) {
|
|
864
|
-
if (to.charCodeAt(toStart) !== 47 /*/*/)
|
|
865
|
-
break;
|
|
866
|
-
}
|
|
867
|
-
var toEnd = to.length;
|
|
868
|
-
var toLen = toEnd - toStart;
|
|
869
|
-
|
|
870
|
-
// Compare paths to find the longest common path from root
|
|
871
|
-
var length = fromLen < toLen ? fromLen : toLen;
|
|
872
|
-
var lastCommonSep = -1;
|
|
873
|
-
var i = 0;
|
|
874
|
-
for (; i <= length; ++i) {
|
|
875
|
-
if (i === length) {
|
|
876
|
-
if (toLen > length) {
|
|
877
|
-
if (to.charCodeAt(toStart + i) === 47 /*/*/) {
|
|
878
|
-
// We get here if `from` is the exact base path for `to`.
|
|
879
|
-
// For example: from='/foo/bar'; to='/foo/bar/baz'
|
|
880
|
-
return to.slice(toStart + i + 1);
|
|
881
|
-
} else if (i === 0) {
|
|
882
|
-
// We get here if `from` is the root
|
|
883
|
-
// For example: from='/'; to='/foo'
|
|
884
|
-
return to.slice(toStart + i);
|
|
885
|
-
}
|
|
886
|
-
} else if (fromLen > length) {
|
|
887
|
-
if (from.charCodeAt(fromStart + i) === 47 /*/*/) {
|
|
888
|
-
// We get here if `to` is the exact base path for `from`.
|
|
889
|
-
// For example: from='/foo/bar/baz'; to='/foo/bar'
|
|
890
|
-
lastCommonSep = i;
|
|
891
|
-
} else if (i === 0) {
|
|
892
|
-
// We get here if `to` is the root.
|
|
893
|
-
// For example: from='/foo'; to='/'
|
|
894
|
-
lastCommonSep = 0;
|
|
895
|
-
}
|
|
896
|
-
}
|
|
897
|
-
break;
|
|
898
|
-
}
|
|
899
|
-
var fromCode = from.charCodeAt(fromStart + i);
|
|
900
|
-
var toCode = to.charCodeAt(toStart + i);
|
|
901
|
-
if (fromCode !== toCode)
|
|
902
|
-
break;
|
|
903
|
-
else if (fromCode === 47 /*/*/)
|
|
904
|
-
lastCommonSep = i;
|
|
905
|
-
}
|
|
906
|
-
|
|
907
|
-
var out = '';
|
|
908
|
-
// Generate the relative path based on the path difference between `to`
|
|
909
|
-
// and `from`
|
|
910
|
-
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
|
|
911
|
-
if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) {
|
|
912
|
-
if (out.length === 0)
|
|
913
|
-
out += '..';
|
|
914
|
-
else
|
|
915
|
-
out += '/..';
|
|
916
|
-
}
|
|
917
|
-
}
|
|
918
|
-
|
|
919
|
-
// Lastly, append the rest of the destination (`to`) path that comes after
|
|
920
|
-
// the common path parts
|
|
921
|
-
if (out.length > 0)
|
|
922
|
-
return out + to.slice(toStart + lastCommonSep);
|
|
923
|
-
else {
|
|
924
|
-
toStart += lastCommonSep;
|
|
925
|
-
if (to.charCodeAt(toStart) === 47 /*/*/)
|
|
926
|
-
++toStart;
|
|
927
|
-
return to.slice(toStart);
|
|
928
|
-
}
|
|
929
|
-
},
|
|
930
|
-
|
|
931
|
-
_makeLong: function _makeLong(path) {
|
|
932
|
-
return path;
|
|
933
|
-
},
|
|
934
|
-
|
|
935
|
-
dirname: function dirname(path) {
|
|
936
|
-
assertPath(path);
|
|
937
|
-
if (path.length === 0) return '.';
|
|
938
|
-
var code = path.charCodeAt(0);
|
|
939
|
-
var hasRoot = code === 47 /*/*/;
|
|
940
|
-
var end = -1;
|
|
941
|
-
var matchedSlash = true;
|
|
942
|
-
for (var i = path.length - 1; i >= 1; --i) {
|
|
943
|
-
code = path.charCodeAt(i);
|
|
944
|
-
if (code === 47 /*/*/) {
|
|
945
|
-
if (!matchedSlash) {
|
|
946
|
-
end = i;
|
|
947
|
-
break;
|
|
948
|
-
}
|
|
949
|
-
} else {
|
|
950
|
-
// We saw the first non-path separator
|
|
951
|
-
matchedSlash = false;
|
|
952
|
-
}
|
|
953
|
-
}
|
|
954
|
-
|
|
955
|
-
if (end === -1) return hasRoot ? '/' : '.';
|
|
956
|
-
if (hasRoot && end === 1) return '//';
|
|
957
|
-
return path.slice(0, end);
|
|
958
|
-
},
|
|
959
|
-
|
|
960
|
-
basename: function basename(path, ext) {
|
|
961
|
-
if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string');
|
|
962
|
-
assertPath(path);
|
|
963
|
-
|
|
964
|
-
var start = 0;
|
|
965
|
-
var end = -1;
|
|
966
|
-
var matchedSlash = true;
|
|
967
|
-
var i;
|
|
968
|
-
|
|
969
|
-
if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
|
|
970
|
-
if (ext.length === path.length && ext === path) return '';
|
|
971
|
-
var extIdx = ext.length - 1;
|
|
972
|
-
var firstNonSlashEnd = -1;
|
|
973
|
-
for (i = path.length - 1; i >= 0; --i) {
|
|
974
|
-
var code = path.charCodeAt(i);
|
|
975
|
-
if (code === 47 /*/*/) {
|
|
976
|
-
// If we reached a path separator that was not part of a set of path
|
|
977
|
-
// separators at the end of the string, stop now
|
|
978
|
-
if (!matchedSlash) {
|
|
979
|
-
start = i + 1;
|
|
980
|
-
break;
|
|
981
|
-
}
|
|
982
|
-
} else {
|
|
983
|
-
if (firstNonSlashEnd === -1) {
|
|
984
|
-
// We saw the first non-path separator, remember this index in case
|
|
985
|
-
// we need it if the extension ends up not matching
|
|
986
|
-
matchedSlash = false;
|
|
987
|
-
firstNonSlashEnd = i + 1;
|
|
988
|
-
}
|
|
989
|
-
if (extIdx >= 0) {
|
|
990
|
-
// Try to match the explicit extension
|
|
991
|
-
if (code === ext.charCodeAt(extIdx)) {
|
|
992
|
-
if (--extIdx === -1) {
|
|
993
|
-
// We matched the extension, so mark this as the end of our path
|
|
994
|
-
// component
|
|
995
|
-
end = i;
|
|
996
|
-
}
|
|
997
|
-
} else {
|
|
998
|
-
// Extension does not match, so our result is the entire path
|
|
999
|
-
// component
|
|
1000
|
-
extIdx = -1;
|
|
1001
|
-
end = firstNonSlashEnd;
|
|
1002
|
-
}
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length;
|
|
1008
|
-
return path.slice(start, end);
|
|
1009
|
-
} else {
|
|
1010
|
-
for (i = path.length - 1; i >= 0; --i) {
|
|
1011
|
-
if (path.charCodeAt(i) === 47 /*/*/) {
|
|
1012
|
-
// If we reached a path separator that was not part of a set of path
|
|
1013
|
-
// separators at the end of the string, stop now
|
|
1014
|
-
if (!matchedSlash) {
|
|
1015
|
-
start = i + 1;
|
|
1016
|
-
break;
|
|
1017
|
-
}
|
|
1018
|
-
} else if (end === -1) {
|
|
1019
|
-
// We saw the first non-path separator, mark this as the end of our
|
|
1020
|
-
// path component
|
|
1021
|
-
matchedSlash = false;
|
|
1022
|
-
end = i + 1;
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
|
|
1026
|
-
if (end === -1) return '';
|
|
1027
|
-
return path.slice(start, end);
|
|
1028
|
-
}
|
|
1029
|
-
},
|
|
1030
|
-
|
|
1031
|
-
extname: function extname(path) {
|
|
1032
|
-
assertPath(path);
|
|
1033
|
-
var startDot = -1;
|
|
1034
|
-
var startPart = 0;
|
|
1035
|
-
var end = -1;
|
|
1036
|
-
var matchedSlash = true;
|
|
1037
|
-
// Track the state of characters (if any) we see before our first dot and
|
|
1038
|
-
// after any path separator we find
|
|
1039
|
-
var preDotState = 0;
|
|
1040
|
-
for (var i = path.length - 1; i >= 0; --i) {
|
|
1041
|
-
var code = path.charCodeAt(i);
|
|
1042
|
-
if (code === 47 /*/*/) {
|
|
1043
|
-
// If we reached a path separator that was not part of a set of path
|
|
1044
|
-
// separators at the end of the string, stop now
|
|
1045
|
-
if (!matchedSlash) {
|
|
1046
|
-
startPart = i + 1;
|
|
1047
|
-
break;
|
|
1048
|
-
}
|
|
1049
|
-
continue;
|
|
1050
|
-
}
|
|
1051
|
-
if (end === -1) {
|
|
1052
|
-
// We saw the first non-path separator, mark this as the end of our
|
|
1053
|
-
// extension
|
|
1054
|
-
matchedSlash = false;
|
|
1055
|
-
end = i + 1;
|
|
1056
|
-
}
|
|
1057
|
-
if (code === 46 /*.*/) {
|
|
1058
|
-
// If this is our first dot, mark it as the start of our extension
|
|
1059
|
-
if (startDot === -1)
|
|
1060
|
-
startDot = i;
|
|
1061
|
-
else if (preDotState !== 1)
|
|
1062
|
-
preDotState = 1;
|
|
1063
|
-
} else if (startDot !== -1) {
|
|
1064
|
-
// We saw a non-dot and non-path separator before our dot, so we should
|
|
1065
|
-
// have a good chance at having a non-empty extension
|
|
1066
|
-
preDotState = -1;
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
|
|
1070
|
-
if (startDot === -1 || end === -1 ||
|
|
1071
|
-
// We saw a non-dot character immediately before the dot
|
|
1072
|
-
preDotState === 0 ||
|
|
1073
|
-
// The (right-most) trimmed path component is exactly '..'
|
|
1074
|
-
preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
1075
|
-
return '';
|
|
1076
|
-
}
|
|
1077
|
-
return path.slice(startDot, end);
|
|
1078
|
-
},
|
|
1079
|
-
|
|
1080
|
-
format: function format(pathObject) {
|
|
1081
|
-
if (pathObject === null || typeof pathObject !== 'object') {
|
|
1082
|
-
throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject);
|
|
1083
|
-
}
|
|
1084
|
-
return _format('/', pathObject);
|
|
1085
|
-
},
|
|
1086
|
-
|
|
1087
|
-
parse: function parse(path) {
|
|
1088
|
-
assertPath(path);
|
|
1089
|
-
|
|
1090
|
-
var ret = { root: '', dir: '', base: '', ext: '', name: '' };
|
|
1091
|
-
if (path.length === 0) return ret;
|
|
1092
|
-
var code = path.charCodeAt(0);
|
|
1093
|
-
var isAbsolute = code === 47 /*/*/;
|
|
1094
|
-
var start;
|
|
1095
|
-
if (isAbsolute) {
|
|
1096
|
-
ret.root = '/';
|
|
1097
|
-
start = 1;
|
|
1098
|
-
} else {
|
|
1099
|
-
start = 0;
|
|
1100
|
-
}
|
|
1101
|
-
var startDot = -1;
|
|
1102
|
-
var startPart = 0;
|
|
1103
|
-
var end = -1;
|
|
1104
|
-
var matchedSlash = true;
|
|
1105
|
-
var i = path.length - 1;
|
|
1106
|
-
|
|
1107
|
-
// Track the state of characters (if any) we see before our first dot and
|
|
1108
|
-
// after any path separator we find
|
|
1109
|
-
var preDotState = 0;
|
|
1110
|
-
|
|
1111
|
-
// Get non-dir info
|
|
1112
|
-
for (; i >= start; --i) {
|
|
1113
|
-
code = path.charCodeAt(i);
|
|
1114
|
-
if (code === 47 /*/*/) {
|
|
1115
|
-
// If we reached a path separator that was not part of a set of path
|
|
1116
|
-
// separators at the end of the string, stop now
|
|
1117
|
-
if (!matchedSlash) {
|
|
1118
|
-
startPart = i + 1;
|
|
1119
|
-
break;
|
|
1120
|
-
}
|
|
1121
|
-
continue;
|
|
1122
|
-
}
|
|
1123
|
-
if (end === -1) {
|
|
1124
|
-
// We saw the first non-path separator, mark this as the end of our
|
|
1125
|
-
// extension
|
|
1126
|
-
matchedSlash = false;
|
|
1127
|
-
end = i + 1;
|
|
1128
|
-
}
|
|
1129
|
-
if (code === 46 /*.*/) {
|
|
1130
|
-
// If this is our first dot, mark it as the start of our extension
|
|
1131
|
-
if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1;
|
|
1132
|
-
} else if (startDot !== -1) {
|
|
1133
|
-
// We saw a non-dot and non-path separator before our dot, so we should
|
|
1134
|
-
// have a good chance at having a non-empty extension
|
|
1135
|
-
preDotState = -1;
|
|
1136
|
-
}
|
|
1137
|
-
}
|
|
1138
|
-
|
|
1139
|
-
if (startDot === -1 || end === -1 ||
|
|
1140
|
-
// We saw a non-dot character immediately before the dot
|
|
1141
|
-
preDotState === 0 ||
|
|
1142
|
-
// The (right-most) trimmed path component is exactly '..'
|
|
1143
|
-
preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) {
|
|
1144
|
-
if (end !== -1) {
|
|
1145
|
-
if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end);
|
|
1146
|
-
}
|
|
1147
|
-
} else {
|
|
1148
|
-
if (startPart === 0 && isAbsolute) {
|
|
1149
|
-
ret.name = path.slice(1, startDot);
|
|
1150
|
-
ret.base = path.slice(1, end);
|
|
1151
|
-
} else {
|
|
1152
|
-
ret.name = path.slice(startPart, startDot);
|
|
1153
|
-
ret.base = path.slice(startPart, end);
|
|
1154
|
-
}
|
|
1155
|
-
ret.ext = path.slice(startDot, end);
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
|
-
if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/';
|
|
1159
|
-
|
|
1160
|
-
return ret;
|
|
1161
|
-
},
|
|
1162
|
-
|
|
1163
|
-
sep: '/',
|
|
1164
|
-
delimiter: ':',
|
|
1165
|
-
win32: null,
|
|
1166
|
-
posix: null
|
|
1167
|
-
};
|
|
1168
|
-
|
|
1169
|
-
posix.posix = posix;
|
|
1170
|
-
|
|
1171
|
-
var pathBrowserify = posix;
|
|
1172
|
-
|
|
1173
673
|
function ensure_list(obj) {
|
|
1174
674
|
const objArray = Array.isArray(obj) ? obj : [obj];
|
|
1175
675
|
return objArray;
|
|
@@ -1792,28 +1292,28 @@ function getAbsolutePath() {
|
|
|
1792
1292
|
function get_dirname(filePath) {
|
|
1793
1293
|
if (!filePath)
|
|
1794
1294
|
return '';
|
|
1795
|
-
return
|
|
1295
|
+
return path__namespace$1.dirname(filePath);
|
|
1796
1296
|
}
|
|
1797
1297
|
function get_basename(filePath) {
|
|
1798
1298
|
if (!filePath)
|
|
1799
1299
|
return '';
|
|
1800
|
-
return
|
|
1300
|
+
return path__namespace$1.basename(filePath);
|
|
1801
1301
|
}
|
|
1802
1302
|
function get_filename(file_path) {
|
|
1803
|
-
const ext =
|
|
1804
|
-
return
|
|
1303
|
+
const ext = path__namespace$1.extname(file_path);
|
|
1304
|
+
return path__namespace$1.basename(file_path, ext);
|
|
1805
1305
|
}
|
|
1806
1306
|
function get_extname(filePath) {
|
|
1807
1307
|
if (!filePath)
|
|
1808
1308
|
return '';
|
|
1809
|
-
return
|
|
1309
|
+
return path__namespace$1.extname(filePath);
|
|
1810
1310
|
}
|
|
1811
1311
|
function get_splitext(filePath) {
|
|
1812
1312
|
if (!filePath)
|
|
1813
1313
|
return { filename: '', extname: '' };
|
|
1814
|
-
const ext =
|
|
1314
|
+
const ext = path__namespace$1.extname(filePath);
|
|
1815
1315
|
// Get the basename without the extension
|
|
1816
|
-
const filename =
|
|
1316
|
+
const filename = path__namespace$1.basename(filePath, ext);
|
|
1817
1317
|
return { filename, ext };
|
|
1818
1318
|
}
|
|
1819
1319
|
/**
|
|
@@ -1871,11 +1371,11 @@ function sanitizeFilename(filename) {
|
|
|
1871
1371
|
.replace(/^-|-$/, ''); // Remove leading/trailing hyphens
|
|
1872
1372
|
}
|
|
1873
1373
|
function get_relative_path(directory, fullPath) {
|
|
1874
|
-
return
|
|
1374
|
+
return path__namespace$1.relative(directory, fullPath);
|
|
1875
1375
|
}
|
|
1876
1376
|
// Safer resolver that strips .. at the front only, but prefer server-side checks.
|
|
1877
1377
|
function get_safe_path(p) {
|
|
1878
|
-
return
|
|
1378
|
+
return path__namespace$1.normalize(p).replace(/^(\.\.[/\\])+/, '');
|
|
1879
1379
|
}
|
|
1880
1380
|
function make_sanitized_path(...paths) {
|
|
1881
1381
|
let real_path = '';
|