aboutsummaryrefslogtreecommitdiff
path: root/node_modules/webpack/lib/util/identifier.js
blob: b1bcbf5dfed53a5edd1c5d820c6e9c89ec9525ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"use strict";
const path = require("path");

const looksLikeAbsolutePath = (maybeAbsolutePath) => {
	return /^(?:[a-z]:\\|\/)/i.test(maybeAbsolutePath);
};

const normalizePathSeparator = (p) => p.replace(/\\/g, "/");

exports.makePathsRelative = (context, identifier) => {
	return identifier
		.split(/([|! ])/)
		.map(str => looksLikeAbsolutePath(str) ?
			normalizePathSeparator(path.relative(context, str)) : str)
		.join("");
};