Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update index.js #106

Merged
merged 12 commits into from
Oct 6, 2020
Merged

Update index.js #106

merged 12 commits into from
Oct 6, 2020

Conversation

uzaysan
Copy link
Contributor

@uzaysan uzaysan commented Oct 5, 2020

Make baseUrl parameter function

@uzaysan
Copy link
Contributor Author

uzaysan commented Oct 5, 2020

This is my first PR ever to any project.

My motivation behind doing this is I have an Nginx server. Its a reverse proxy with caching system. Its acting like a CDN.
I have images and videos. I would like to seperate this two type of objects like this:

if(filename.endsWith(".jpeg"){
    baseUrl = image.myserver.com/files/
}
if(filename.endsWith(".mp4"){
    baseUrl = videos.myserver.com/files/;

    //Or even split more
    var c = filename.substr(0, 1);
    if (c >= '0' && c <= '9') {
        // it is a number
        baseUrl = video4.server.com
    } else {
        // it isn't
        baseUrl = videos2.server.com
    }
}

I hope I explained myself good. I'm not a professional. Sorry for mistakes.

@davimacedo
Copy link
Member

Thanks for the PR. It looks good to me. Few things:

@uzaysan
Copy link
Contributor Author

uzaysan commented Oct 6, 2020

@davimacedo when you say fix the link problems, you mean these:

  163:7   error  Expected space(s) after "if"                                                  keyword-spacing
  163:24  error  Missing space before opening brace                                            space-before-blocks
  166:43  error  A space is required after ','                                                 comma-spacing
  168:41  error  A space is required after ','                                                 comma-spacing
  169:9   error  Closing curly brace does not appear on the same line as the subsequent block  brace-style
  170:9   error  Expected space(s) after "else"                                                keyword-spacing
  170:13  error  Unnecessary 'else' after 'return'                                             no-else-return
  176:1   error  Trailing spaces not allowed                                                   no-trailing-spaces
  177:7   error  Block must not be padded by blank lines                                       padded-blocks

I believe I can fix them.

But I dont know how to write tests. Like I said I'm not a professional. I'm a law school student. And I do programming as a hobby.
But I will try my best.

@davimacedo
Copy link
Member

davimacedo commented Oct 6, 2020

Sorry I said link but it is lint. For the test case, you can duplicate this section and add similar test cases but passing a function instead of a string. By doing this we will make sure that your addition will not only work but also nobody will break it in the future.

@uzaysan
Copy link
Contributor Author

uzaysan commented Oct 6, 2020

@davimacedo I fixed the lint problems. Now I will try to write some tests. I will edit test.spec.js file in my own branch and push it right?

@uzaysan
Copy link
Contributor Author

uzaysan commented Oct 6, 2020

@davimacedo I believe I wrote a succesfull test. You can look it here And it passes every check.

Copy link
Member

@davimacedo davimacedo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job! LGTM!

@davimacedo davimacedo merged commit 93427da into parse-community:master Oct 6, 2020
@uzaysan
Copy link
Contributor Author

uzaysan commented Oct 7, 2020

@davimacedo Thank you. When will these changes be available on npm?

@davimacedo
Copy link
Member

I am not sure of the exact date, but I'm working to have a new release of Parse Server soon with this.

mtrezza added a commit to mtrezza/parse-server-s3-adapter that referenced this pull request Oct 13, 2020
* commit '73b3c780f0aca1011029012c13dd700accc577c1':
  Upgrade Parse to version 2.17.0 (parse-community#109)
  Replace greenkeeper badge with synk (parse-community#108)
  Update index.js (parse-community#106)
  Release v1.5.0 (parse-community#105)
  Update parse and aws-sdk to the latest versions (parse-community#104)
  Bump node-fetch from 2.6.0 to 2.6.1 (parse-community#103)
  fix: upgrade parse from 2.14.0 to 2.15.0 (parse-community#101)
  fix: upgrade aws-sdk from 2.706.0 to 2.709.0 (parse-community#98)
  fix: upgrade parse from 2.13.0 to 2.14.0 (parse-community#99)
  fix: upgrade aws-sdk from 2.705.0 to 2.706.0 (parse-community#96)
  Bump codecov from 3.6.5 to 3.7.1 (parse-community#97)
  fix: upgrade aws-sdk from 2.59.0 to 2.705.0
  Bump lodash from 4.17.15 to 4.17.19
  fix: upgrade parse from 2.10.0 to 2.13.0 (parse-community#93)
@@ -353,6 +353,49 @@ describe('S3Adapter tests', () => {
expect(s3.getFileLocation(testConfig, 'test.png')).toEqual('https://myBucket.s3.amazonaws.com/foo/bar/test.png');
});
});
describe('getFileLocation', () => {
const testConfig = {
mount: 'http://my.server.com/parse',
Copy link
Member

@mtrezza mtrezza Oct 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not use invented domain names such as server.com for testing purposes, that goes against RFC2606. IANA reserved example.* domains for that purpose.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I learnt something today!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants