mancha 0.3.11 → 0.3.13
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/browser.js +1 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -3
- package/dist/mancha.js +1 -1
- package/dist/web.d.ts +2 -0
- package/dist/web.js +22 -3
- package/package.json +1 -1
- package/yarn-error.log +3935 -0
package/dist/web.d.ts
CHANGED
|
@@ -18,3 +18,5 @@ export declare function renderLocalPath(fpath: string, vars?: {
|
|
|
18
18
|
export declare function renderRemotePath(fpath: string, vars?: {
|
|
19
19
|
[key: string]: string;
|
|
20
20
|
}): Promise<string>;
|
|
21
|
+
export declare function folderPath(fpath: string): string;
|
|
22
|
+
export declare function resolvePath(fpath: string): string;
|
package/dist/web.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.renderRemotePath = exports.renderLocalPath = exports.renderContent = exports.preprocess = exports.decodeHtmlAttrib = exports.encodeHtmlAttrib = void 0;
|
|
12
|
+
exports.resolvePath = exports.folderPath = exports.renderRemotePath = exports.renderLocalPath = exports.renderContent = exports.preprocess = exports.decodeHtmlAttrib = exports.encodeHtmlAttrib = void 0;
|
|
13
13
|
const dom_serializer_1 = require("dom-serializer");
|
|
14
14
|
const htmlparser2 = require("htmlparser2");
|
|
15
15
|
const path = require("path-browserify");
|
|
@@ -74,7 +74,7 @@ function preprocess(content, vars) {
|
|
|
74
74
|
exports.preprocess = preprocess;
|
|
75
75
|
function renderContent(content, vars = {}, fsroot = null, maxdepth = 10, _renderLocalPathFunc = renderLocalPath) {
|
|
76
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
fsroot = fsroot || self.location.href
|
|
77
|
+
fsroot = fsroot || folderPath(self.location.href) + "/";
|
|
78
78
|
const preprocessed = preprocess(content, vars);
|
|
79
79
|
const document = parseDocument(preprocessed);
|
|
80
80
|
const childNodes = Array.from(document.childNodes);
|
|
@@ -143,7 +143,26 @@ exports.renderLocalPath = renderLocalPath;
|
|
|
143
143
|
function renderRemotePath(fpath, vars = {}) {
|
|
144
144
|
return __awaiter(this, void 0, void 0, function* () {
|
|
145
145
|
const content = yield fetch(fpath).then((res) => res.text());
|
|
146
|
-
return renderContent(content, vars,
|
|
146
|
+
return renderContent(content, vars, folderPath(fpath));
|
|
147
147
|
});
|
|
148
148
|
}
|
|
149
149
|
exports.renderRemotePath = renderRemotePath;
|
|
150
|
+
function folderPath(fpath) {
|
|
151
|
+
if (fpath.endsWith("/")) {
|
|
152
|
+
return fpath.slice(0, -1);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
return path.dirname(fpath);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
exports.folderPath = folderPath;
|
|
159
|
+
function resolvePath(fpath) {
|
|
160
|
+
if (fpath.includes("://")) {
|
|
161
|
+
const [scheme, remotePath] = fpath.split("://", 2);
|
|
162
|
+
return `${scheme}://${resolvePath("/" + remotePath).substring(1)}`;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
return path.resolve(fpath);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.resolvePath = resolvePath;
|