1 | "use strict"
|
2 |
|
3 | module.exports = function getMode(pluginSettings, filenameOrOptions) {
|
4 | const filename =
|
5 | typeof filenameOrOptions === "object"
|
6 | ? filenameOrOptions.filename
|
7 | : filenameOrOptions
|
8 |
|
9 | if (!filename) {
|
10 | return
|
11 | }
|
12 | if (pluginSettings.htmlExtensions.some(hasExtension)) {
|
13 | return "html"
|
14 | }
|
15 | if (pluginSettings.xmlExtensions.some(hasExtension)) {
|
16 | return "xml"
|
17 | }
|
18 |
|
19 | function hasExtension(extension) {
|
20 | if (!extension.startsWith(".")) {
|
21 | extension = `.${extension}`
|
22 | }
|
23 | return filename.endsWith(extension)
|
24 | }
|
25 | }
|