Skip to content

Commit

Permalink
Add regex to trim title's leading and trailing whitespaces, in comput…
Browse files Browse the repository at this point in the history
…eUrl

Sample usage: " pokemon " => "pokemon".
Bump up to version 0.2.3
  • Loading branch information
gorlandor committed Sep 29, 2016
1 parent b9caa16 commit 6f78474
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ A Polymer custom element that fetches movie, series, episode data from the

# Change Log

Version: 0.2.2
- Remove redundant css properties
Version: 0.2.3
- Add regex to trim the title's leading and trailing whitespaces, in computeUrl


# Demo it
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "omdb-search",
"version": "0.2.2",
"version": "0.2.3",
"authors": [
"Giovanni Orlando Rivera <gorlandor@gmail.com>"
],
Expand Down
24 changes: 12 additions & 12 deletions omdb-search.html
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,15 @@ <h4 class="result__heading">{{item.Title}}</h4>
* Specifies the movie, series, or episode title to query.
* Search value.
* Is required. */
q: {
q: {
type: String,
value: 'Harry Potter',
notify: true
},
/**
* Search result type. Can be either movie, series, or episode.
* Is Optional. */
type: {
type: {
type: String,
value: "movie",
notify: true
Expand All @@ -207,7 +207,7 @@ <h4 class="result__heading">{{item.Title}}</h4>
* Number representing the year in which the movie, series,
* or episode was released.
* Is optional. */
year: {
year: {
type: Number,
value: '',
notify: true
Expand All @@ -216,7 +216,7 @@ <h4 class="result__heading">{{item.Title}}</h4>
* Specifies the data-interchange format to be used in ajax call.
* Can be either json, or xml.
* Is required. */
responseType: {
responseType: {
type: String,
value: 'json',
notify: false
Expand All @@ -225,7 +225,7 @@ <h4 class="result__heading">{{item.Title}}</h4>
* Specifies the results-list page number,
* since OMDb pages search results (10 results per page).
* Is optional. */
page: {
page: {
type: Number,
value: 1,
notify: true
Expand All @@ -234,15 +234,15 @@ <h4 class="result__heading">{{item.Title}}</h4>
* Specified the OMDb API version number, for future reference
* when said API updated.
* Is optional. */
apiVersion: {
apiVersion: {
type: Number,
value: 1,
notify: false
},
/**
* Url computed from user assigned element props.
* Is required. */
url: {
url: {
computed: 'computeUrl(q, type, year, responseType, page, apiVersion)'
},
/**
Expand All @@ -257,17 +257,17 @@ <h4 class="result__heading">{{item.Title}}</h4>
/**
* Computes and returns the request Url from the
* user assigned element props. */
computeUrl: function(q, type, year, responseType, page, apiVersion) {
return `https://www.omdbapi.com/?s=${q}&type=${type}&y=${year}
computeUrl: function(q, type, year, responseType, page, apiVersion) {
return `https://www.omdbapi.com/?s=${ q.replace(/^\s+|\s+$/g, '') }&type=${type}&y=${year}
&r=${responseType}'&page=${page}&v=${apiVersion}`;
},
/**
* Checks if the image source value received as input is valid,
* otherwise returns empty string to default to the alt text. */
_computeImgSrc: function(src) {
_computeImgSrc: function(src) {
return (src === 'N/A')
? "../images/omdb-search.png"
: src;
? "../images/omdb-search.png"
: src;
},
/**
* Used as the iron-ajax response handler function. */
Expand Down

0 comments on commit 6f78474

Please sign in to comment.