@docusaurus/core
Version:
Easy to Maintain Open Source Documentation Websites
16 lines (15 loc) • 561 B
JavaScript
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// Poor man's protocol detection
// Spec: https://datatracker.ietf.org/doc/html/rfc3986#section-3.1
// In particular: scheme = ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
export function hasProtocol(url) {
return /^(?:[A-Za-z][A-Za-z\d+.-]*:|\/\/)/.test(url);
}
export default function isInternalUrl(url) {
return typeof url !== 'undefined' && !hasProtocol(url);
}