package/package.json000666 000000 000000 0000001351 12612550642012774 0ustar00000000 000000 { "name": "uri-path", "version": "1.0.0", "description": "Convert relative file system paths into safe URI paths", "main": "index.js", "scripts": { "test": "mocha" }, "repository": { "type": "git", "url": "https://github.com/UltCombo/uri-path.git" }, "keywords": [ "uri", "url", "relative", "file system", "fs", "path", "convert" ], "author": { "name": "Ult Combo", "email": "ultcombo@gmail.com" }, "engines": { "node": ">= 0.10" }, "license": "WTFPL OR MIT", "bugs": { "url": "https://github.com/UltCombo/uri-path/issues" }, "homepage": "https://github.com/UltCombo/uri-path", "devDependencies": { "mocha": "^2.3.3", "should": "^7.1.1" } } package/.npmignore000666 000000 000000 0000000036 12354115366012507 0ustar00000000 000000 /node_modules/ /npm-debug.log package/README.md000666 000000 000000 0000001474 12366636471012006 0ustar00000000 000000 # uri-path [![NPM version](https://badge.fury.io/js/uri-path.png)](https://npmjs.org/package/uri-path) [![Build Status](https://travis-ci.org/UltCombo/uri-path.png?branch=master)](https://travis-ci.org/UltCombo/uri-path) [![devDependency Status](https://david-dm.org/UltCombo/uri-path/dev-status.png)](https://david-dm.org/UltCombo/uri-path#info=devDependencies) Convert relative file system paths into safe URI paths # Install ``` npm install --save uri-path ``` # Usage ```js var URIpath = require('uri-path'); // Properly encode URI path segments URIpath('../abc/@#$%¨&()[]{}-_=+ß/môòñ 月 قمر'); // -> '../abc/%40%23%24%25%C2%A8%26()%5B%5D%7B%7D-_%3D%2B%C3%9F/m%C3%B4%C3%B2%C3%B1%20%E6%9C%88%20%D9%82%D9%85%D8%B1' // Also supports paths with Windows directory separators URIpath('a\\b\\c'); // -> 'a/b/c' ``` package/index.js000666 000000 000000 0000000172 12612537241012153 0ustar00000000 000000 'use strict'; module.exports = function(path) { return path.split(/[\\\/]/g).map(encodeURIComponent).join('/'); }; package/LICENSE-WTFPL000666 000000 000000 0000000762 12266634040012412 0ustar00000000 000000 DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Copyright (C) 2004 Sam Hocevar Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. You just DO WHAT THE FUCK YOU WANT TO. package/.travis.yml000666 000000 000000 0000000046 12354125434012617 0ustar00000000 000000 language: node_js node_js: - "0.10" package/CONTRIBUTING.md000666 000000 000000 0000000166 12354143440012737 0ustar00000000 000000 See [Ult Foundation Contributor's Guide](https://github.com/UltFoundation/Ultiomatic.js/blob/master/CONTRIBUTING.md). package/LICENSE-MIT000666 000000 000000 0000002073 12561060670012144 0ustar00000000 000000 The MIT License (MIT) Copyright (c) 2015 Fabrício Matté Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. package/test/main.js000666 000000 000000 0000001053 12612537505012751 0ustar00000000 000000 'use strict'; var URIpath = require('..'); require('should'); describe('uri-path', function() { it('should convert relative file system paths into properly encoded URIs', function() { var paths = { // file system path: expected URI path '../abc/@#$%¨&()[]{}-_=+ß/môòñ 月 قمر': '../abc/%40%23%24%25%C2%A8%26()%5B%5D%7B%7D-_%3D%2B%C3%9F/m%C3%B4%C3%B2%C3%B1%20%E6%9C%88%20%D9%82%D9%85%D8%B1', 'a\\b\\c': 'a/b/c', }; Object.keys(paths).forEach(function(filePath) { URIpath(filePath).should.equal(paths[filePath]); }); }); });