This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/clean-css/lib/reader/extract-import-url-and-media.js

36 lines
854 B
JavaScript
Raw Permalink Normal View History

2019-08-11 18:48:02 +00:00
var split = require('../utils/split');
var BRACE_PREFIX = /^\(/;
var BRACE_SUFFIX = /\)$/;
var IMPORT_PREFIX_PATTERN = /^@import/i;
var QUOTE_PREFIX_PATTERN = /['"]\s*/;
var QUOTE_SUFFIX_PATTERN = /\s*['"]/;
var URL_PREFIX_PATTERN = /^url\(\s*/i;
var URL_SUFFIX_PATTERN = /\s*\)/i;
function extractImportUrlAndMedia(atRuleValue) {
var uri;
var mediaQuery;
var stripped;
var parts;
stripped = atRuleValue
.replace(IMPORT_PREFIX_PATTERN, '')
.trim()
.replace(URL_PREFIX_PATTERN, '(')
.replace(URL_SUFFIX_PATTERN, ')')
.replace(QUOTE_PREFIX_PATTERN, '')
.replace(QUOTE_SUFFIX_PATTERN, '');
parts = split(stripped, ' ');
uri = parts[0]
.replace(BRACE_PREFIX, '')
.replace(BRACE_SUFFIX, '');
mediaQuery = parts.slice(1).join(' ');
return [uri, mediaQuery];
}
module.exports = extractImportUrlAndMedia;