How to use the urijs.domAttributes function in urijs

To help you get started, we’ve selected a few urijs 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 medialize / ally.js / build / metalsmith / plugins / absolute-url.js View on Github external
as allowing the metalsmith link-checker to work properly.

  USAGE:

    provide metalsmith.data.root.websiteRoot for use in templates
    absoluteUrl({ property: "websiteRoot", define: "/hello/world" })

    convert all URLs beginning with websiteRoot to relative URLs
    absoluteUrl({ resolve: "/hello/world", canonical: "https://example.org/" })
*/

const path = require('path');
const cheerio = require('cheerio');
const URI = require('urijs');

const urlSelector = Object.keys(URI.domAttributes).map(function(tagName) {
  return tagName + '[' + URI.domAttributes[tagName] + ']';
}).join(',');

function filter(file, files, filePath /*, options */) {
  // skip mutations for anything that isn't html
  if (filePath.ext !== '.html') {
    return true;
  }

  return false;
}

function transform($, file, fileName, options) {
  const absolute = path.join(options.resolve, fileName);
  if (options.canonical) {
    const canonical = options.canonical + fileName;
github medialize / ally.js / build / metalsmith / plugins / absolute-url.js View on Github external
const urlSelector = Object.keys(URI.domAttributes).map(function(tagName) {
  return tagName + '[' + URI.domAttributes[tagName] + ']';
}).join(',');