source: trip-planner-front/node_modules/adjust-sourcemap-loader/codec/output-root-relative.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.0 KB
Line 
1'use strict';
2
3var relative = require('./output-relative');
4
5/**
6 * Codec for relative paths with respect to the output directory.
7 * @type {{name:string, decode: function, encode: function, root: function}}
8 */
9module.exports = {
10 name : 'outputRootRelative',
11 decode: decode,
12 encode: encode,
13 root : relative.root
14};
15
16/**
17 * Decode the given uri.
18 * Any path with leading slash is tested against output directory.
19 * @this {{options: object}} A loader or compilation
20 * @param {string} uri A source uri to decode
21 * @returns {boolean|string} False where unmatched else the decoded path
22 */
23function decode(uri) {
24 /* jshint validthis:true */
25 return uri.startsWith('/') && relative.decode.call(this, uri.slice(1));
26}
27
28/**
29 * Encode the given file path.
30 * @this {{options: object}} A loader or compilation
31 * @param {string} absolute An absolute file path to encode
32 * @returns {string} A uri with leading slash
33 */
34function encode(absolute) {
35 /* jshint validthis:true */
36 return '/' + relative.encode.call(this, absolute);
37}
Note: See TracBrowser for help on using the repository browser.