Skip to content

Commit 351a321

Browse files
authored
Support opts.from as a URL (#21)
1 parent 2539052 commit 351a321

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

parse.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ function parse (source, opts) {
1111
opts.syntax = this;
1212
}
1313
let rules = opts.syntax.config.rules;
14+
const file = opts.from ? opts.from.replace(/^(\w+:\/\/.*?\.\w+)(?:[?#].*)?$/, "$1") : "";
1415
rules = rules && rules.filter(
15-
rule => rule.test.test(opts.from || "")
16+
rule => rule.test.test(file)
1617
);
1718
source = source.toString();
1819
return processor(source, rules, opts) || parser(source, rules, opts);

test/load-syntax.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe("load-syntax", () => {
1313
"</template>",
1414
].join("\n"), {
1515
syntax,
16-
from: "quickapp.ax",
16+
from: "http://somehost.com/??quickapp.ax?v=102234",
1717
}).then(result => {
1818
expect(result.root.nodes).to.have.lengthOf(2);
1919
});
@@ -22,9 +22,8 @@ describe("load-syntax", () => {
2222
return postcss().process([
2323
"<template>",
2424
"\t<span style=\"color:{{notice.color}};font-size:{{notice.font_size}}px\" for=\"{{(index,notice) in showModalData.notice}}\">{{notice.txt}}</span>",
25-
"\t<span style=\"color:{{notice.color}};font-size:{{notice.font_size}}px\" for=\"{{(index,notice) in showModalData.notice}}\">{{notice.txt}}</span>",
25+
"\t<span style=\"a {\" for=\"{{(index,notice) in showModalData.notice}}\">{{notice.txt}}</span>",
2626
"</template>",
27-
2827
].join("\n"), {
2928
syntax: syntax({
3029
css: require.resolve("postcss-safe-parser"),

0 commit comments

Comments
 (0)