Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

custom URL scheme upper case letters not working #2309

Merged
merged 6 commits into from
Mar 23, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
recognize scheme with lower and upper case
  • Loading branch information
Hobby-Student authored and Christian committed Mar 23, 2019
commit 917b52f10135499615d25a34dd6d463ecf10e521
11 changes: 3 additions & 8 deletions utils/markdown/renderer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -144,24 +144,19 @@ export default class Renderer extends marked.Renderer {
let outHref = href;

if (!href.startsWith('/')) {
console.log("href before scheme: ", href);
const scheme = getScheme(href);
console.log("scheme: ", scheme);
if (!scheme) {
console.log("scheme: false");
outHref = `https://${outHref}`;
outHref = `https://${outHref}`;
} else if (isUrl && this.formattingOptions.autolinkedUrlSchemes) {
const isValidUrl = this.formattingOptions.autolinkedUrlSchemes.indexOf(scheme) !== -1;
const isValidUrl = this.formattingOptions.autolinkedUrlSchemes.indexOf(scheme.toLowerCase()) !== -1;

if (!isValidUrl) {
console.log("isValidUrl: false");
return text;
return text;
}
}
}

if (!isUrlSafe(unescapeHtmlEntities(href))) {
console.log("isUrlSafe: false");
return text;
}

Expand Down
2 changes: 1 addition & 1 deletion utils/url.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function useSafeUrl(url, defaultUrl = '') {
}

export function getScheme(url) {
const match = (/([A-Za-z0-9+.-]+):/i).exec(url);
const match = (/([a-z0-9+.-]+):/i).exec(url);

return match && match[1];
}