Skip to content

Commit c1ebb10

Browse files
committed
fix clean url
1 parent 833b3ae commit c1ebb10

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

Parser.js

Lines changed: 3 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"license": "BSD-4-Clause",
99
"author": "SegmentFault",
10-
"version": "2.4.17",
10+
"version": "2.4.18",
1111
"scripts": {
1212
"test": "mocha",
1313
"build": "cake build"

src/Parser.coffee

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -988,12 +988,11 @@ class Parser
988988

989989

990990
cleanUrl: (url) ->
991-
if !!(matches = url.match /^\s*(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&\/=]*))/)
992-
matches[1]
993-
else if !!(matches = url.match /^\s*([-a-zA-Z0-9()@:%_\+.~#?&\/=]+)/)
994-
matches[1]
995-
else
996-
'#'
991+
url = url.replace /["'<>\s]/g, ''
992+
993+
return '#' if (url.match /^\w+:/i) and not (url.match /^https?:/i)
994+
995+
url
997996

998997

999998
escapeBracket: (str) ->

0 commit comments

Comments
 (0)