Skip to content

Commit

Permalink
Added support for absolute link urls
Browse files Browse the repository at this point in the history
  • Loading branch information
nozer committed Aug 14, 2018
1 parent 8eb593c commit 37e2f1d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/browser/QuillDeltaToHtmlConverter.bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ String.prototype._tokenizeWithNewLines = function () {
String.prototype._sanitizeUrl = function () {
var val = this;
val = val.replace(/^\s*/gm, '');
var whiteList = /^\s*((|https?|s?ftp|file|blob|mailto|tel):|#|data:image\/)/;
var whiteList = /^\s*((|https?|s?ftp|file|blob|mailto|tel):|#|\/|data:image\/)/;
if (whiteList.test(String(val))) {
return val;
}
Expand Down
2 changes: 1 addition & 1 deletion dist/commonjs/extensions/String.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ String.prototype._tokenizeWithNewLines = function () {
String.prototype._sanitizeUrl = function () {
var val = this;
val = val.replace(/^\s*/gm, '');
var whiteList = /^\s*((|https?|s?ftp|file|blob|mailto|tel):|#|data:image\/)/;
var whiteList = /^\s*((|https?|s?ftp|file|blob|mailto|tel):|#|\/|data:image\/)/;
if (whiteList.test(String(val))) {
return val;
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "quill-delta-to-html",
"version": "0.9.4",
"version": "0.9.5",
"description": "Converts Quill's delta ops to HTML",
"main": "./dist/commonjs/main.js",
"types":"./dist/commonjs/main.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/String.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ String.prototype._tokenizeWithNewLines = function() {
String.prototype._sanitizeUrl = function() {
let val = this;
val = val.replace(/^\s*/gm, '')
let whiteList = /^\s*((|https?|s?ftp|file|blob|mailto|tel):|#|data:image\/)/;
let whiteList = /^\s*((|https?|s?ftp|file|blob|mailto|tel):|#|\/|data:image\/)/;
if (whiteList.test(String(val))) {
return val;
}
Expand Down
3 changes: 3 additions & 0 deletions test/extensions/String.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ describe("String Extensions Module", function(){
act = "#abc"._sanitizeUrl();
assert.equal(act, "#abc");

act = "/abc"._sanitizeUrl();
assert.equal(act, "/abc");

act = " data:image//abc"._sanitizeUrl();
assert.equal(act, "data:image//abc");

Expand Down

0 comments on commit 37e2f1d

Please sign in to comment.