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

OCS API should return fancy OC url #14998

Merged
merged 2 commits into from
Mar 24, 2015
Merged

OCS API should return fancy OC url #14998

merged 2 commits into from
Mar 24, 2015

Conversation

rullzer
Copy link
Contributor

@rullzer rullzer commented Mar 18, 2015

Right now the OCS API still returns the old url for link shares. It should use the fancy new shorter url.

Pretty trivial fix - just a tiny thing that annoys me way more than it should

@@ -303,8 +303,7 @@ public static function createShare($params) {
break;
}
}
$url = \OCP\Util::linkToPublic('files&t='.$token);
$data['url'] = $url; // '&' gets encoded to $amp;
$data['url'] = \OCP\Util::linkToPublic('files') . '/' . $token;
Copy link
Member

Choose a reason for hiding this comment

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

Can you try to use the URLGenerator using the route? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My quick and dirty fix not good enough 😜 ? But you are right. I'll have a look later.

Copy link
Member

Choose a reason for hiding this comment

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

🙈 😄

@karlitschek
Copy link
Contributor

👍
What do you think @schiesbn

@icewind1991
Copy link
Contributor

Code looks good 👍

@@ -303,8 +303,7 @@ public static function createShare($params) {
break;
}
}
$url = \OCP\Util::linkToPublic('files&t='.$token);
$data['url'] = $url; // '&' gets encoded to $amp;
$data['url'] = \OC::$server->getURLGenerator()->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', ['token' => $token]);
Copy link
Member

Choose a reason for hiding this comment

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

this adds the hard dependency that the route name never changes - I'd really welcome a unit test which double checks that the proper url is being generated

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If an invalid route name is provided stuff breaks here. So a lot of unit tests already fail.

Do we really want a unit test to check for this the correct url? The whole point of the URLGenerator is so we can change the generated url as long as the route name stays the same.

The only thing that might make it break is if somebody swaps the names of two functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What could be done is check for a somewhat valid url? So that it at least an absolute url and contains the token.

Copy link
Member

Choose a reason for hiding this comment

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

I'd assert $data['url'] to match http://localhost/index.php/s/12345678

Copy link
Contributor

Choose a reason for hiding this comment

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

http://localhost/index.php/s/12345678

which would fail on ~50% of the dev installations, instead you can use the makeAbsolute from the url generator to make the expected string adapt to the install

@rullzer rullzer mentioned this pull request Mar 20, 2015
@scrutinizer-notifier
Copy link

The inspection completed: 1 updated code elements

@rullzer
Copy link
Contributor Author

rullzer commented Mar 21, 2015

Finally Jenkins is Happy with the unit test (see #15085 )

Review time :)

@icewind1991
Copy link
Contributor

👍

1 similar comment
@MorrisJobke
Copy link
Contributor

👍

MorrisJobke added a commit that referenced this pull request Mar 24, 2015
OCS API should return fancy OC url
@MorrisJobke MorrisJobke merged commit 2370af6 into owncloud:master Mar 24, 2015
@rullzer rullzer deleted the ocs_api_new_url branch March 24, 2015 16:06
@lock lock bot locked as resolved and limited conversation to collaborators Aug 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants