FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
openapi-typescript-codegen/src/utils/getPattern.ts at main · thulium/openapi-typescript-codegen · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
thulium
/
openapi-typescript-codegen
Public
forked from
ferdikoomen/openapi-typescript-codegen
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
21
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
openapi-typescript-codegen
/
src
/
utils
/
getPattern.ts
Copy path
More file actions
More file actions
Latest commit
History
History
History
14 lines (14 loc) · 543 Bytes
Breadcrumbs
openapi-typescript-codegen
/
src
/
utils
/
getPattern.ts
Copy path
File metadata and controls
14 lines (14 loc) · 543 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/**
* The spec generates a pattern like this '^\d{3}-\d{2}-\d{4}$'
* However, to use it in HTML or inside new RegExp() we need to
* escape the pattern to become: '^\\d{3}-\\d{2}-\\d{4}$' in order
* to make it a valid regexp string.
*
* Also, escape single quote characters, because the output uses single quotes for strings
*
*
@param
pattern
*/
export
const
getPattern
=
(
pattern
?:
string
)
:
string
|
undefined
=>
{
// eslint-disable-next-line prettier/prettier
return
pattern
?.
replace
(
/
\\
/
g
,
'\\\\'
)
.
replace
(
/
'
/
g
,
"\\'"
)
;
}
;
Back
|
FazBrowse Home
|
New Git URL