File tree Expand file tree Collapse file tree 2 files changed +24
-3
lines changed
Expand file tree Collapse file tree 2 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 11( function ( ) {
22 'use strict' ;
33
4+ var REGEX_BOOKMARK_SCHEME = / ^ # .* / i;
45 var REGEX_EMAIL_SCHEME = / ^ [ a - z 0 - 9 \u0430 - \u044F \. _ - ] + @ / i;
56 var REGEX_URI_SCHEME = / ^ (?: [ a - z ] [ a - z 0 - 9 + \- . ] * ) \: | ^ \/ / i;
67
214215 } ,
215216
216217 /**
217- * Checks if the URI has an '@' symbol. If it does and the URI looks like an email
218- * and doesn't have 'mailto:', 'mailto:' is added to the URI.
218+ * Checks if the URI begins with a '#' symbol to determine if it's an on page bookmark.
219+ * If it doesn't, it then checks if the URI has an '@' symbol. If it does and the URI
220+ * looks like an email and doesn't have 'mailto:', 'mailto:' is added to the URI.
219221 * If it doesn't and the URI doesn't have a scheme, the default 'http' scheme with
220222 * hierarchical path '//' is added to the URI.
221223 *
227229 * @return {String } The URI updated with the protocol.
228230 */
229231 _getCompleteURI : function ( URI ) {
230- if ( REGEX_EMAIL_SCHEME . test ( URI ) ) {
232+ if ( REGEX_BOOKMARK_SCHEME . test ( URI ) ) {
233+ return URI ;
234+ } else if ( REGEX_EMAIL_SCHEME . test ( URI ) ) {
231235 URI = 'mailto:' + URI ;
232236 } else if ( ! REGEX_URI_SCHEME . test ( URI ) ) {
233237 URI = this . appendProtocol ? 'http://' + URI : URI ;
Original file line number Diff line number Diff line change 8282 assert . strictEqual ( data , '<p>set a <a href="//test.com" target="_blank">selection</a> and then convert it to a link.</p>' ) ;
8383 } ) ;
8484
85+ it ( 'should not add default protocol if link is an on page bookmark' , function ( ) {
86+ var link = new CKEDITOR . Link ( this . nativeEditor ) ;
87+
88+ bender . tools . selection . setWithHtml ( this . nativeEditor , 'set a {selection} and then convert it to a link.' ) ;
89+
90+ link . create ( '#bookmark' , {
91+ target : '_blank'
92+ } ) ;
93+
94+ var data = bender . tools . getData ( this . nativeEditor , {
95+ fixHtml : true ,
96+ compatHtml : true
97+ } ) ;
98+
99+ assert . strictEqual ( data , '<p>set a <a href="#bookmark" target="_blank">selection</a> and then convert it to a link.</p>' ) ;
100+ } ) ;
101+
85102 it ( 'should add mailto: when creating an email link' , function ( ) {
86103 var link = new CKEDITOR . Link ( this . nativeEditor ) ;
87104
You can’t perform that action at this time.
0 commit comments