How to use is-absolute-url - 9 common examples

To help you get started, we’ve selected a few is-absolute-url examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SparkPost / heml / packages / heml-elements / src / Img.js View on Github external
async function getWidth (path, isRetina) {
  try {
    const image = await (isAbsoluteUrl(path) ? getRemoteBuffer(path) : fs.readFile(path))

    const { width } = sizeOf(image)
    if (!width) { return 'auto' }

    return isRetina ? Math.round(width / 2) : width
  } catch (e) {
    return 'auto' // if we fail fall back to auto
  }
}
github styled-system / styled-system / docs / src / link.js View on Github external
export const Link = ({ href, ...props }) =>
  isHash(href) || isAbsoluteURL(href) ? (
    // eslint-disable-next-line
    <a href="{href}">
  ) : (
    
  )
</a>
github taskcluster / taskcluster / ui / src / utils / Link.jsx View on Github external
export default function Link({ nav, to, skipPrefetch, ...props }) {
  let shouldReload = false;
  const path = typeof to === 'string' ? to : to.pathname;
  const isPathAbsolute = isAbsolute(path);
  const Component = nav ? NavLink : RouterLink;
  const [prefetchFlag, setPrefetchFlag] = useState(false);

  function prefetch() {
    if (prefetchFlag) {
      return;
    }

    if (!isPathAbsolute) {
      const matchingRoutes = matchRoutes(path, Link.routes);
      const components = matchingRoutes.map(({ component }) =>
        component.preload()
      );

      Promise.all(components).catch(() => {
        shouldReload = true;
github datosgobar / consulta-publica / ext / lib / header / component.js View on Github external
const Logo = () =&gt; {
  const isAbsolute = isAbsoluteUrl(config.homeLink)

  const Element = isAbsolute ? React.DOM.a : Link

  const props = {
    className: 'logo',
    [isAbsolute ? 'href' : 'to']: config.homeLink,
    rel: isAbsolute ? 'noopener nofollow' : null
  }

  return (
    <element>
      <img src="{config.logo}">
      <img src="{config.logoMobile}">
    </element>
  )
}
github sourcegraph / sourcegraph / web / src / components / RouterLinkOrAnchor.tsx View on Github external
export const RouterLinkOrAnchor: React.FunctionComponent = props =&gt;
    typeof props.to === 'string' &amp;&amp; isAbsoluteUrl(props.to) ? <a href="{props.to}"> : 
</a>
github firefox-devtools / vscode-firefox-debug / src / adapter / util / pathMapper.ts View on Github external
public convertFirefoxSourceToPath(source: FirefoxDebugProtocol.Source): string | undefined {
		if (!source) return undefined;

		if (source.addonID && this.addonConfig && (source.addonID === this.addonConfig.id)) {

			let sourcePath = this.removeQueryString(path.join(this.addonConfig.path, source.addonPath!));
			log.debug(`Addon script path: ${sourcePath}`);
			return sourcePath;

		} else if (source.isSourceMapped && source.generatedUrl && source.url && !isAbsoluteUrl(source.url)) {

			let originalPathOrUrl = source.url;

			if (path.isAbsolute(originalPathOrUrl)) {

				log.debug(`Sourcemapped absolute path: ${originalPathOrUrl}`);

				if (isWindowsPlatform) {
					originalPathOrUrl = path.normalize(originalPathOrUrl);
				}

				return originalPathOrUrl;

			} else {

				let generatedUrl = source.generatedUrl;
github facultyai / dash-bootstrap-components / src / private / Link.js View on Github external
function isExternalLink(external_link, href) {
  if (typeof external_link === 'undefined' || external_link === null) {
    return isAbsoluteUrl(href);
  }
  return external_link;
}
github MunifTanjim / gatsby-theme-dox / theme / src / components / Link.js View on Github external
function Link({ to = '', href = to, children, ...props }) {
  const isAbsoluteLink = isAbsoluteURL(href)

  return isAbsoluteLink ? (
    <a href="{href}">
      {children}
    </a>
  ) : (
    
      {children}
    
  )
}

is-absolute-url

Check if a URL is absolute

MIT
Latest version published 3 years ago

Package Health Score

70 / 100
Full package analysis

Popular is-absolute-url functions