How to use urlencode - 10 common examples

To help you get started, we’ve selected a few urlencode 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 DefinitelyTyped / DefinitelyTyped / types / urlencode / urlencode-tests.ts View on Github external
import urlencode from 'urlencode';

urlencode('苏千'); // default is utf8
urlencode('苏千', 'gbk'); // '%CB%D5%C7%A7'

// decode gbk
urlencode.decode('%CB%D5%C7%A7', 'gbk'); // '苏千'

// parse gbk querystring
urlencode.parse('nick=%CB%D5%C7%A7', {charset: 'gbk'}); // {nick: '苏千'}

// stringify obj with gbk encoding
const str = 'x[y][0][v][w]=' + urlencode('雾空', 'gbk'); // x[y][0][v][w]=%CE%ED%BF%D5
const obj =  {x: {y : [{v : {w : '雾空'}}]}};
urlencode.stringify(obj, {charset: 'gbk'});
github DefinitelyTyped / DefinitelyTyped / types / urlencode / urlencode-tests.ts View on Github external
import urlencode from 'urlencode';

urlencode('苏千'); // default is utf8
urlencode('苏千', 'gbk'); // '%CB%D5%C7%A7'

// decode gbk
urlencode.decode('%CB%D5%C7%A7', 'gbk'); // '苏千'

// parse gbk querystring
urlencode.parse('nick=%CB%D5%C7%A7', {charset: 'gbk'}); // {nick: '苏千'}

// stringify obj with gbk encoding
const str = 'x[y][0][v][w]=' + urlencode('雾空', 'gbk'); // x[y][0][v][w]=%CE%ED%BF%D5
const obj =  {x: {y : [{v : {w : '雾空'}}]}};
urlencode.stringify(obj, {charset: 'gbk'});
github DefinitelyTyped / DefinitelyTyped / types / urlencode / urlencode-tests.ts View on Github external
import urlencode from 'urlencode';

urlencode('苏千'); // default is utf8
urlencode('苏千', 'gbk'); // '%CB%D5%C7%A7'

// decode gbk
urlencode.decode('%CB%D5%C7%A7', 'gbk'); // '苏千'

// parse gbk querystring
urlencode.parse('nick=%CB%D5%C7%A7', {charset: 'gbk'}); // {nick: '苏千'}

// stringify obj with gbk encoding
const str = 'x[y][0][v][w]=' + urlencode('雾空', 'gbk'); // x[y][0][v][w]=%CE%ED%BF%D5
const obj =  {x: {y : [{v : {w : '雾空'}}]}};
urlencode.stringify(obj, {charset: 'gbk'});
github DefinitelyTyped / DefinitelyTyped / types / urlencode / urlencode-tests.ts View on Github external
import urlencode from 'urlencode';

urlencode('苏千'); // default is utf8
urlencode('苏千', 'gbk'); // '%CB%D5%C7%A7'

// decode gbk
urlencode.decode('%CB%D5%C7%A7', 'gbk'); // '苏千'

// parse gbk querystring
urlencode.parse('nick=%CB%D5%C7%A7', {charset: 'gbk'}); // {nick: '苏千'}

// stringify obj with gbk encoding
const str = 'x[y][0][v][w]=' + urlencode('雾空', 'gbk'); // x[y][0][v][w]=%CE%ED%BF%D5
const obj =  {x: {y : [{v : {w : '雾空'}}]}};
urlencode.stringify(obj, {charset: 'gbk'});
github DefinitelyTyped / DefinitelyTyped / types / urlencode / urlencode-tests.ts View on Github external
import urlencode from 'urlencode';

urlencode('苏千'); // default is utf8
urlencode('苏千', 'gbk'); // '%CB%D5%C7%A7'

// decode gbk
urlencode.decode('%CB%D5%C7%A7', 'gbk'); // '苏千'

// parse gbk querystring
urlencode.parse('nick=%CB%D5%C7%A7', {charset: 'gbk'}); // {nick: '苏千'}

// stringify obj with gbk encoding
const str = 'x[y][0][v][w]=' + urlencode('雾空', 'gbk'); // x[y][0][v][w]=%CE%ED%BF%D5
const obj =  {x: {y : [{v : {w : '雾空'}}]}};
urlencode.stringify(obj, {charset: 'gbk'});
github felixfbecker / vscode-php-debug / src / paths.ts View on Github external
export function convertDebuggerPathToClient(
    fileUri: string | url.Url,
    pathMapping?: { [index: string]: string }
): string {
    let localSourceRoot: string | undefined
    let serverSourceRoot: string | undefined
    if (typeof fileUri === 'string') {
        fileUri = url.parse(fileUri)
    }
    // convert the file URI to a path
    let serverPath = decode(fileUri.pathname!)
    // strip the trailing slash from Windows paths (indicated by a drive letter with a colon)
    const serverIsWindows = /^\/[a-zA-Z]:\//.test(serverPath)
    if (serverIsWindows) {
        serverPath = serverPath.substr(1)
    }
    if (pathMapping) {
        for (const mappedServerPath of Object.keys(pathMapping)) {
            const mappedLocalSource = pathMapping[mappedServerPath]
            // normalize slashes for windows-to-unix
            const serverRelative = (serverIsWindows ? path.win32 : path.posix).relative(mappedServerPath, serverPath)
            if (serverRelative.indexOf('..') !== 0) {
                serverSourceRoot = mappedServerPath
                localSourceRoot = mappedLocalSource
                break
            }
        }
github JGAntunes / hapi-uploader / lib / uploader.js View on Github external
function saveFile (data, fileName, cb) {
    const mimeType = data.hapi.headers['content-type']
    const name = fileName || urlencode.decode(data.hapi.filename, 'utf8')
    const file = data
    const filePath = path.join(uploadPath, name)
    const fileStream = fs.createWriteStream(filePath)
    const fileInfo = {
      mimeType,
      name,
      path: filePath,
      extension: Mime.extension(mimeType)
    }

    fileStream.on('error', (err) => {
      if (err && err.errno === 34) {
        // Still not sure if throw is the best to go here
        log(['error'], new Error(
          'Error while saving file, possible issue with path - ' +
          err
github sofastack / sofa-rpc-node / lib / registry / zk / data_client.js View on Github external
async register(config) {
    assert(config && config.interfaceName, '[ZookeeperRegistry] register(config) config.interfaceName is required');
    assert(config.url, '[ZookeeperRegistry] register(config) config.url is required');
    const providerPath = this._buildProviderPath(config);
    await this._zkClient.mkdirp(providerPath);
    const path = providerPath + '/' + urlencode.encode(config.url);
    this._registerMap.set(path, config);
    try {
      // NOTE: Maybe the path is invalid, so remove it first
      if (await this._zkClient.exists(path)) {
        await this._remove(path);
      }
      await this._zkClient.create(path, EMPTY, this.options.ephemeralNode ? CreateMode.EPHEMERAL : CreateMode.PERSISTENT);
    } catch (err) {
      if (err.name === 'NODE_EXISTS' && err.code === -110) {
        return;
      }
      throw err;
    }
  }
github TheBrainFamily / TheBrain2.0 / server / src / api / mongooseSetup.js View on Github external
const generateResetPasswordToken = async (userId) => {
  const rawToken = `${userId}_W3GojrLkVLKH9l`
  // we are using hashing function as a clean way to generate a random string
  const salt = await bcrypt.genSalt(Math.random())
  return urlencode.encode(await bcrypt.hash(rawToken, salt))
}
github TheBrainFamily / TheBrain2.0 / server / src / api / repositories / UsersRepository.js View on Github external
const generateResetPasswordToken = async (userId) => {
  const rawToken = `${userId}_W3GojrLkVLKH9l`
  // we are using hashing function as a clean way to generate a random string
  const salt = await bcrypt.genSalt(SALT_WORK_FACTOR)
  return urlencode.encode(await bcrypt.hash(rawToken, salt))
}

urlencode

encodeURIComponent with charset

MIT
Latest version published 1 year ago

Package Health Score

60 / 100
Full package analysis