MCPcopy Create free account
hub / github.com/CoderLine/alphaTab / absoluteToRequest

Function absoluteToRequest

packages/webpack/src/AlphaTabWebPackPlugin.ts:35–61  ·  view source on GitHub ↗
(context: string, maybeAbsolutePath: string)

Source from the content-addressed store, hash-verified

33};
34
35const absoluteToRequest = (context: string, maybeAbsolutePath: string): string => {
36 if (maybeAbsolutePath[0] === '/') {
37 if (maybeAbsolutePath.length > 1 && maybeAbsolutePath[maybeAbsolutePath.length - 1] === '/') {
38 // this 'path' is actually a regexp generated by dynamic requires.
39 // Don't treat it as an absolute path.
40 return maybeAbsolutePath;
41 }
42
43 const querySplitPos = maybeAbsolutePath.indexOf('?');
44 let resource = querySplitPos === -1 ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos);
45 resource = relativePathToRequest(path.posix.relative(context, resource));
46 return querySplitPos === -1 ? resource : resource + maybeAbsolutePath.slice(querySplitPos);
47 }
48
49 if (WINDOWS_ABS_PATH_REGEXP.test(maybeAbsolutePath)) {
50 const querySplitPos = maybeAbsolutePath.indexOf('?');
51 let resource = querySplitPos === -1 ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos);
52 resource = path.win32.relative(context, resource);
53 if (!WINDOWS_ABS_PATH_REGEXP.test(resource)) {
54 resource = relativePathToRequest(resource.replace(WINDOWS_PATH_SEPARATOR_REGEXP, '/'));
55 }
56 return querySplitPos === -1 ? resource : resource + maybeAbsolutePath.slice(querySplitPos);
57 }
58
59 // not an absolute path
60 return maybeAbsolutePath;
61};
62
63const _contextify = (context: string, request: string): string => {
64 return request

Callers 1

_contextifyFunction · 0.85

Calls 5

relativePathToRequestFunction · 0.85
replaceMethod · 0.80
testMethod · 0.65
indexOfMethod · 0.45
sliceMethod · 0.45

Tested by

no test coverage detected