stackoverflow-careers
Version:
A wrapper for the StackOverflow careers feed.
46 lines (41 loc) • 1.11 kB
JavaScript
const EncodedCharacters = {
'!': '%21',
'"': '%22',
'#': '%23',
'$': '%24',
'%': '%25',
'&': '%26',
'\'': '%27',
'(': '%28',
')': '%29',
'*': '%2A',
'+': '%2B',
',': '%2C',
'-': '%2D',
'.': '%2E',
'/': '%2F',
' ': '%20',
};
const Utils = {
UrlPrefix: 'https://stackoverflow.com/jobs/feed?',
Query: 'q=',
Location: "&l=",
Unit: "&u=",
TechLiked: "&tl=",
TechDisliked: "&td=",
/**
* Converts protected HTML characters and converts them to their encoded version. Eg: # -> %23
* @param {String} param - A string with (potentially) encoded characters
*/
EncodeProtectedCharacters(param) {
const paramSplit = param.split('');
let convertedCharacters = '';
paramSplit.forEach(char => {
(Object.prototype.hasOwnProperty.call(EncodedCharacters, char)) ? convertedCharacters += EncodedCharacters[char] : convertedCharacters += char;
});
return convertedCharacters;
}
}
module.exports = {
Utils,
}