FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
JavaScript/Regex/validURL.js at master · lgope/JavaScript · GitHub
lgope
/
JavaScript
Public
Notifications
You must be signed in to change notification settings
Fork
4
Star
11
Code
Issues
0
Pull requests
2
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
JavaScript
/
Regex
/
validURL.js
Copy path
More file actions
More file actions
Latest commit
History
History
History
11 lines (10 loc) · 456 Bytes
Breadcrumbs
JavaScript
/
Regex
/
validURL.js
Copy path
File metadata and controls
11 lines (10 loc) · 456 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
const
validURL
=
(
str
)
=>
{
const
pattern
=
new
RegExp
(
'^(https?:\\/\\/)?'
+
// protocol
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|'
+
// domain name
'((\\d{1,3}\\.){3}\\d{1,3}))'
+
// OR ip (v4) address
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'
+
// port and path
'(\\?[;&a-z\\d%_.~+=-]*)?'
+
// query string
'(\\#[-a-z\\d_]*)?$'
,
'i'
)
;
// fragment locator
return
!
!
pattern
.
test
(
str
)
;
}
console
.
log
(
validURL
(
"https://www.google.com/"
)
)
;
Back
|
FazBrowse Home
|
New Git URL