Advertisement
Guest User

Untitled

a guest
Jan 12th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. module.exports.DSN = function() {
  2. this.setPath = function(path) {
  3. this.path = path;
  4. };
  5. this.getPath = function() {
  6. return this.path;
  7. };
  8. this.getPort = function() {
  9. return this.port;
  10. };
  11. this.setPort = function(port) {
  12. this.port = port;
  13. };
  14. this.setHost = function(host) {
  15. this.host = host;
  16. }
  17. this.getHost = function() {
  18. return this.host;
  19. };
  20. this.setProtocol = function(proto) {
  21. this.proto = proto;
  22. };
  23. this.getProtocol = function() {
  24. return this.proto;
  25. };
  26. this.setUsername = function(user) {
  27. this.user = user;
  28. };
  29. this.getUsername = function() {
  30. return this.user;
  31. };
  32. this.setPass = function(pass) {
  33. this.pass = pass;
  34. };
  35. this.getPass = function() {
  36. return this.pass;
  37. };
  38. this.toString = function() {
  39. if (this.host === undefined) {
  40. return; // There is no host, we can't do anything
  41. }
  42. var result = this.host;
  43. if (this.port !== undefined) {
  44. result += ":" + this.port;
  45. }
  46. if (this.path !== undefined) {
  47. result += "/" + this.path;
  48. }
  49. var userString = "";
  50. if (this.user !== undefined) {
  51. userString = this.user;
  52. }
  53. if (this.pass !== undefined) {
  54. userString += ":" + this.pass;
  55. }
  56. if (userString !== "") {
  57. result = userString + "@" + result;
  58. }
  59. if (this.proto !== undefined) {
  60. result = this.proto + "://" + result;
  61. }
  62. return result;
  63. };
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement