-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove more browsers and the AMD malarkey
- Loading branch information
Showing
2 changed files
with
33 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,23 @@ | ||
if (typeof define !== 'function') { var define = require('amdefine')(module) } | ||
|
||
define(function () { | ||
return function pctEncode(regexp) { | ||
regexp = regexp || /\W/g; | ||
return function encode(string) { | ||
string = String(string); | ||
return string.replace(regexp, function (m) { | ||
var c = m[0].charCodeAt(0) | ||
, encoded = []; | ||
if (c < 128) { | ||
encoded.push(c); | ||
} else if ((128 <= c && c < 2048)) { | ||
encoded.push((c >> 6) | 192); | ||
encoded.push((c & 63) | 128); | ||
} else { | ||
encoded.push((c >> 12) | 224); | ||
encoded.push(((c >> 6) & 63) | 128); | ||
encoded.push((c & 63) | 128); | ||
} | ||
return encoded.map(function (c) { | ||
return '%' + c.toString(16).toUpperCase(); | ||
}).join(''); | ||
}) | ||
} | ||
module.exports = function pctEncode(regexp) { | ||
regexp = regexp || /\W/g; | ||
return function encode(string) { | ||
string = String(string); | ||
return string.replace(regexp, function (m) { | ||
var c = m[0].charCodeAt(0) | ||
, encoded = []; | ||
if (c < 128) { | ||
encoded.push(c); | ||
} else if ((128 <= c && c < 2048)) { | ||
encoded.push((c >> 6) | 192); | ||
encoded.push((c & 63) | 128); | ||
} else { | ||
encoded.push((c >> 12) | 224); | ||
encoded.push(((c >> 6) & 63) | 128); | ||
encoded.push((c & 63) | 128); | ||
} | ||
return encoded.map(function (c) { | ||
return '%' + c.toString(16).toUpperCase(); | ||
}).join(''); | ||
}) | ||
} | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters