Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80668 views
1
/**
2
* Copyright 2013 Facebook, Inc.
3
*
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
7
*
8
* http://www.apache.org/licenses/LICENSE-2.0
9
*
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
15
*/
16
17
var fbSpriteRe = /-fb-sprite\s*:\s*url\s*\(\s*[\'"]?([^\'")]+)[\'"]?\s*\)/g;
18
var splashRe = /^\//;
19
function extractFBSprites(contents) {
20
var result = {};
21
var match;
22
while (match = fbSpriteRe.exec(contents)) {
23
result[match[1].replace(splashRe, '')] = 1;
24
}
25
return Object.keys(result);
26
}
27
28
var bgRe = /background[^:]*:.*?url\([\']*([^\)]*\/images\/[^\)]+)[\']*\)/g;
29
var quoteRe = /'"/g;
30
function extractBackgroundImages(contents) {
31
var result = {};
32
var match;
33
while (match = bgRe.exec(contents)) {
34
result[match[1].replace(splashRe, '').replace(quoteRe, '')] = 1;
35
}
36
return Object.keys(result);
37
}
38
39
exports.extractFBSprites = extractFBSprites;
40
41