mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-25 17:48:07 +02:00
Simplify some regular expressions
There's a fair number of regular expressions througout the code-base which are slightly more verbose than strictly necessary, in particular: - We have a lot of regular expressions that use `[0-9]` explicitly, and those can be simplified to use `\d` instead. - We have one instance of a regular expression containing a `A-Za-z0-9_` sequence, which can be simplified to use `\w` instead.
This commit is contained in:
parent
0a366dda6a
commit
c42887221a
8 changed files with 35 additions and 38 deletions
|
@ -576,7 +576,7 @@ const FINGERPRINT_FIRST_BYTES = 1024;
|
|||
const EMPTY_FINGERPRINT =
|
||||
"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
|
||||
|
||||
const PDF_HEADER_VERSION_REGEXP = /^[1-9]\.[0-9]$/;
|
||||
const PDF_HEADER_VERSION_REGEXP = /^[1-9]\.\d$/;
|
||||
|
||||
function find(stream, signature, limit = 1024, backwards = false) {
|
||||
if (
|
||||
|
@ -988,7 +988,7 @@ class PDFDocument {
|
|||
}
|
||||
let fontFamily = descriptor.get("FontFamily");
|
||||
// For example, "Wingdings 3" is not a valid font name in the css specs.
|
||||
fontFamily = fontFamily.replace(/[ ]+([0-9])/g, "$1");
|
||||
fontFamily = fontFamily.replace(/[ ]+(\d)/g, "$1");
|
||||
const fontWeight = descriptor.get("FontWeight");
|
||||
|
||||
// Angle is expressed in degrees counterclockwise in PDF
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue