Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. class LinkFinder {
  2. constructor(data, includePrefix, path) {
  3. this.data = data;
  4. this.includePrefix = includePrefix;
  5. this.includeSuffix = checkIfDataNeedsSuffix(this.data.foobar);
  6. this.path = path;
  7. }
  8. urlFor(environment) {
  9. if (environment === 'dev') {
  10. if (this.includeSuffix) {
  11. return null;
  12. }
  13. if (this.includePrefix) {
  14. return URI.expand(DEV_WITH_PREFIX, this.data).toString();
  15. } else {
  16. return URI.expand(DEV_WITHOUT_PREFIX, this.data).toString();
  17. }
  18. }
  19. if (environment === 'int') {
  20. if (this.includeSuffix) {
  21. return null;
  22. }
  23. if (this.includePrefix) {
  24. return URI.expand(INT_WITH_PREFIX, this.data).toString();
  25. } else {
  26. return URI.expand(INT_WITHOUT_PREFIX, this.data).toString();
  27. }
  28. }
  29. if (environment === 'prod') {
  30. if (this.includeSuffix) {
  31. return null;
  32. }
  33. if (this.includePrefix) {
  34. return URI.expand(PROD_WITH_PREFIX, this.data).toString();
  35. } else {
  36. return URI.expand(PROD_WITHOUT_PREFIX, this.data).toString();
  37. }
  38. }
  39. if (environment === 'stage') {
  40. if (this.includeSuffix) {
  41. if (this.includePrefix) {
  42. return URI.expand(STAGE_WITH_SUFFIX_WITH_PREFIX, this.data).toString();
  43. } else {
  44. return URI.expand(STAGE_WITH_SUFFIX_WITHOUT_PREFIX, this.data).toString();
  45. }
  46. } else {
  47. if (this.includePrefix) {
  48. return URI.expand(STAGE_WITHOUT_SUFFIX_WITH_PREFIX, this.data).toString();
  49. } else {
  50. return URI.expand(STAGE_WITHOUT_SUFFIX_WITHOUT_PREFIX, this.data).toString();
  51. }
  52. }
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement