UNPKG

506 BJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const TAG = '~';
4const TAG_SPLIT_REGEX = RegExp(`^([^${TAG}]*)(?:${TAG}([^.]+))?(.*)$`, 'u');
5function splitTaggedFilename(name) {
6 const split = TAG_SPLIT_REGEX.exec(name);
7 if (split == null) {
8 throw new Error(`Could not parse filename ${JSON.stringify(String(name))}`);
9 }
10 const [before, tag, after] = split.slice(1);
11 return { tag, basename: before + after };
12}
13exports.default = splitTaggedFilename;