How to use strict-uri-encode - 5 common examples

To help you get started, we’ve selected a few strict-uri-encode 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 mvila / npm-addict / backend / fetcher.js View on Github external
async getGitHubJSONFile(url, useCache) {
    const cachePath = useCache ? pathModule.join(this.cacheDir, strictUriEncode(url)) : undefined;
    let json;

    if (cachePath) {
      if (fs.existsSync(cachePath)) {
        json = fs.readFileSync(cachePath, 'utf8');
      }
    }

    if (json == null) {
      // await sleep(1500);
      const file = await this.requestGitHubAPI(url);
      if (!file) return false;
      if (file.encoding !== 'base64') {
        this.app.log.warning(`Unsupported GitHub file encoding found while fetching a file (${url}) from GitHub`);
        return undefined;
      }
github WorldBrain / Memex / src / search-injection / components / container.tsx View on Github external
seeMoreResults() {
        // Create a new tab with the query overview URL
        const query = new URL(location.href).searchParams.get('q')
        const finalQuery = strictUriEncode(query)

        this.openOverviewRPC('query=' + finalQuery)
    }
github runtools / run / packages / common / src / index.js View on Github external
export async function getJSON(url, options = {}) {
  let cacheFile;

  if (options.cacheTime) {
    const cacheDir = join(tmpdir(), 'voila-common', 'cache');
    cacheFile = join(cacheDir, strictUriEncode(url));

    let stats;
    try { stats = statSync(cacheFile); } catch (err) { /* File is missing */ }
    if (stats && Date.now() - stats.mtime.getTime() < options.cacheTime) {
      const result = JSON.parse(readFileSync(cacheFile, 'utf8'));
      return result;
    }
  }

  const opts = {
    headers: { 'Accept': 'application/json' }
  };
  if (options.timeout != null) opts.timeout = options.timeout;

  const response = await fetch(url, opts);
  if (response.status !== 200) {
github lukechilds / my-name-is-url / src / main.js View on Github external
// Check input for urls
  let parsedUrls = Urls(input.value).filter(url => `!urlMatchStart${url}!urlMatchEnd`);

  // Escape all HTML chars
  parsedUrls = escape(parsedUrls);

  // Wrap matched urls in spans
  parsedUrls = parsedUrls
    .replace(/!urlMatchStart/g, '<span class="url">')
    .replace(/!urlMatchEnd/g, '</span>');

  // Add parsed urls to output
  output.innerHTML = `${parsedUrls} `;

  // Save current state in url hash
  location.replace(`#${strictUriEncode(input.value)}`);
}
github davidesantangelo / search.feedi.me / src / App.js View on Github external
handlePageClick = data => {
    let selected = data.selected;

    window.location.search = "?q=" + strictUriEncode(this.state.query) + "&page=" + (selected + 1);
  };

strict-uri-encode

A stricter URI encode adhering to RFC 3986

MIT
Latest version published 8 years ago

Package Health Score

67 / 100
Full package analysis

Popular strict-uri-encode functions