0

trying to use https://www.npmjs.org/package/to-uri, but it says toURI function is not defined, how do I make it global or call it from package directly?

Herokiller
  • 2,891
  • 5
  • 32
  • 50

1 Answers1

1

It's a weird module, but this seems to work:

String.prototype.toURI = require('to-uri');
...
var text = 'Тест: Проверим текст на русском языке';
console.log(text.toURI());

This produces the following:

'test-proverim-text-na-russkom-yazyke'
robertklep
  • 198,204
  • 35
  • 394
  • 381