codex-team / codex-team/editor.js
AddProtocol Function in inline-tool-link.ts adds hardcoded http:// also to internal links if used with base tag
- Dominant language
- TypeScript
- Stars
- 31.9k
- Forks
- 2.2k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
In inline-tool-link.ts addProtocol adds a hardcoded http:// to internal Links:
/**
* We need to add missed HTTP protocol to the link, but skip 2 cases:
* 1) Internal links like "/general"
* 2) Anchors looks like "#results"
* 3) Protocol-relative URLs like "//google.com"
*/
const isInternal = /^\/[^/\s]/.test(link),
isAnchor = link.substring(0, 1) === '#',
isProtocolRelative = /^\/\/[^/\s]/.test(link);
if (!isInternal && !isAnchor && !isProtocolRelative) {
link = 'http://' + link;
}
but internal Links can also start without a leading / if they are for instance used in conjunction with html base tag.
Best case IMHO should be a configurable protocol and/or also the option to disable this function with a configurable variable.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.