Skip to content

Commit a7bc586

Browse files
authored
using regex
1 parent 5d2eaec commit a7bc586

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/type/p5.Font.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -983,8 +983,7 @@ async function create(pInst, name, path, descriptors, rawFont) {
983983

984984
function createFontFace(name, path, descriptors, rawFont) {
985985

986-
if (!((name.startsWith("'") && name.endsWith("'")) ||
987-
(name.startsWith('"') && name.endsWith('"')))) {
986+
if (!/^[A-Za-z_][\w-]*$/.test(name)) {
988987
name = "'" + name.replace(/'/g, "\\'") + "'";
989988
}
990989

0 commit comments

Comments
 (0)